I'm having a problem with login to a asp.net. 
Firstly, I use cfhttp to make a request to the login page to get cookie info 
(ASP.NET_SessionId) Secondly, using cfhttp to login (passing ASP.NET_SessionId 
in cfhttpparam type="cookie" and my login details) Finally, I use cfhttp to 
request the index.aspx page to check whether the login is successfull but it 
seems that I couldn't log in. It return me back to the login page.
My code is:
<!--- First http request to get cookie info ---> <cfhttp 
url="http://www.mycompany.com/Login.aspx"; method="get" resolveurl="yes" 
port="80" throwonerror="yes" redirect="yes"
                 useragent="#cgi.HTTP_USER_AGENT#"/>
<!--- create cookieStruct --->
<cfset cookieList = cfhttp.responseheader['Set-Cookie']>
<cfset cookieStruct = Structnew()>
<cfloop from="1" to="#listlen(cookieList,';')#" index="i">  <cfset cookieKV = 
listGetAt(cookieList,i,";")>  <cfif listLen(cookieKV,"=") gt 1>
  <cfset cookieKey = listGetAt(cookieKV,1,"=")>
  <cfset cookieValue = listGetAt(cookieKV,2,"=")>
  cfset structInsert(cookieStruct,cookiekey,cookievalue)>
 </cfif>
</cfloop>

<!--- Second http request to login --->
<cfhttp url="http://www.mycompany.com/Login.aspx"; method="post" 
resolveurl="yes" port="80" 
        throwonerror="yes" redirect="yes"
        useragent="#cgi.HTTP_USER_AGENT#">
<cfloop collection="#cookieStruct#" item="key">
  <cfhttpparam type="cookie" name="#key#" value="#cookieStruct[key]#"> </cfloop>
  <cfhttpparam type="formfield" name="CompanyCode" value="MyCode"/>
  <cfhttpparam type="formfield" name="UserEmail" value="[EMAIL PROTECTED]"/>
  <cfhttpparam type="formfield"  name="UserPassword" value="mypassword"/>
  <cfhttpparam type="formfield"  name="SigninBtn" value="Login"/> </cfhttp>

<!--- Verify whether the login is successful ---> <cfhttp method="get" 
url="http://www.mycompany.com/index.aspx";
        resolveurl="yes" port="80" throwonerror="yes" redirect="yes"> <cfloop 
collection="#cookieStruct#" item="key">
  <cfhttpparam type="cookie" name="#key#" value="#cookieStruct[key]#"> 
</cfloop> </cfhttp>

<!--- If the login is successful then index page will be shown, otherwise,  
login page is shown ---> <cfoutput>#cfhttp.FileContent#"</cfoutput>

I have a look in the cookie if I logged in using html page, i also see cookie 
key .ASPXAUTH and value is E94ED8F.... which I don't see that in the response 
header when using cfhttp.

I think that this might be a well-known problem for many people. 
Does anyone know what the problem is?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:258685
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to