ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 21st, 2005, 10:42 PM
gaming_mouse gaming_mouse is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 16 gaming_mouse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 47 m 20 sec
Reputation Power: 0
Advanced: 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,
gm

Code:
<!---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--->

Reply With Quote
  #2  
Old July 22nd, 2005, 08:37 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
If you dump the cookies that you are setting, do you have a cfide and cftoken or jsessionid? This is what is almost always used to track a user session and thus to enforce security. You could also try passing these identifiers in the URL itself (CF will use them if they are in the URL).

You can also test it be seeing what the identifiers are in your cfhttp tag call and try using them in a real browser request by adding them to the URL.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Advanced: Getting Login-Protected Info With CFHTTP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT