Getting Login-Protected Info With CFHTTP

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Getting Login-Protected Info With CFHTTP

    I wrote a CF script about a year ago that logs onto an informational site at
    which I am member, retrieves some information from the site, and then stores it
    in my personal database. The script has been working fine until about a week
    ago. I can't figure out why it's not working now...

    Here is what the code does:

    1. uses cfhttp to simulate a post with my username/pass to the login page

    2. gets all the cookies the server sends back (session id, etc) and stores
    them in a struct so that when I request further pages I can send the
    appropriate cookies to the server.

    3. as a test, requests the "home" login page -- that is, the default page you
    see after loggin in. dumping the filecontent here confirms that my code is
    still able to login successfully.

    4. requests the page i'm interested in. dumping the filecontent here shows
    that i have been redirected to a "you must be logged in" page.

    when i login manually through a browser, i AM able to successfully go directly
    from the "home" login page to the page i'm interested in, by pasting the
    of-interest URL directly into the address bar once i have logged in. So that
    is why i'm baffled. i've even added the http_referer as a cgi variable in case
    the server was checking that. i've also identified my userAgent as IE.

    Anyone have any ideas what could be going on? What is their server using to
    reject me?

    TIA,
    lurisia

    <!---login and get cookies--->
    <cfhttp
    url="http://www.xxxxxx.com/loginNow.cfm"
    userAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; T312461; .NET
    CLR 1.1.4322)"
    method="post">
    <cfhttpparam type = "formField" name = "username" value = "myUserName"
    encoded="No">
    <cfhttpparam type = "formField" name = "password" value = "myPassword"
    encoded="No">
    <cfhttpparam type = "formField" name="Submit" value="Log in">
    </cfhttp>

    <!---put the cookies in a struct to use in later http calls--->
    <cfset cookies=structNew()>
    <cfloop collection="#cfhttp.responseHeader['Set-Cookie']#" item="i">
    <cfoutput>
    <cfset temp = cfhttp.responseHeader['set-cookie'][i]>
    <cfset temp = REReplace(temp, ";.*", "")>
    <cfset cName = listFirst(temp,"=")>
    <cfset cValue = listLast(temp,"=")>
    <cfset cookies[cName] = cValue>
    </cfoutput>
    </cfloop>

    <cfhttp
    url="http://www.xxxxxx.com/membersonly/main.cfm?l=1"
    userAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; T312461; .NET
    CLR 1.1.4322)"
    >
    <cfloop collection="#cookies#" item="i">
    <cfhttpparam type = "cookie" name="#i#" value="#cookies[i]#">
    </cfloop>
    </cfhttp>
    <!---dumping the filecontent here confirms a successful login--->

    <cfhttp
    url="http://login1.xxxxxx.com/membersonly/search/Statistics/default.cfm"
    userAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; T312461; .NET
    CLR 1.1.4322)">
    <cfhttpparam type = "cgi" name="referer"
    value="http://www.xxxxxx.com/membersonly/main.cfm?l=1">
    <cfloop collection="#cookies#" item="i">
    <cfhttpparam type = "cookie" name="#i#" value="#cookies[i]#">
    </cfloop>
    </cfhttp>

    <!---dumping the filecontent here shows that i have been denied access--->

    lurisia Guest

  2. Similar Questions and Discussions

    1. Strange problem with Forms authentication: After successfull login, login page is still displayed
      Hi there I have a quite strange problem with my ASP.NET-Application. The application has being deployed one year ago and worked fine till last...
    2. info login
      I'm trying to create a website login page/form that has a simple UserName/Password feature. The page/form checks SQL Database Table to see if the...
    3. session problem - login screen continually reloads after pressing the login button
      I am trying to get sessions to work on a log in screen to give certain users access to certain pages/directories. The problem is that when the...
    4. passing user name info to protected page
      Hello. Newbie question I'm sure. I've got this page I am securing with a password using a simple LOGIN.ASPX page: <%@ Page Language="VB" %>...
    5. Protected folder login details
      Hi, I have a folder that is protected, the users login with their unique username and password, these are held in a text file. Is this...
  3. #2

    Default Re: Getting Login-Protected Info With CFHTTP

    > Anyone have any ideas what could be going on? What is their server using
    to
    > reject me?
    Check to see if there are differences between the headers you're sending and
    the ones that the browsers sends (use the LiveHttpHeaders extension for
    Firefox for example).

    --
    <mack />


    Neculai Macarie Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139