The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. December 05, 2008, 11:02:38 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Cookie question with curl  (Read 344 times)
nattsurfaren
Journeyman
***
Offline Offline

Posts: 52


View Profile
« on: July 20, 2008, 03:11:56 PM »

I want to speed up submitting with an auto submitter tool.
So if I'm using curl in php I first load the page and save cookies in a file.
Then I submit the page with the given cookies.

So lets say I want to submit immediately without loading the page first then I need to generate the cookie file myself because I'm reading cookies from  a web browser.

Will I get any problems just submitting without loading if I generate a cookie file?

curl gave me this example in the cookie file:
Code:
# Netscape HTTP Cookie File
# http://curlm.haxx.se/rfc/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.

www.mydomain.info FALSE / FALSE 1216591646 user Alex+Porter

I don't understand the format. I tried to understand the spec but couldn't find any match for this example.


How do I figure this out?
Where can I find information of the parameters?

I appreciate any help you can offer on this.

Cheers!
Natt
« Last Edit: July 20, 2008, 03:15:01 PM by nattsurfaren » Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 5230


:sniffle: Humor was so much easier before.


View Profile
« Reply #1 on: July 20, 2008, 04:42:50 PM »

The problem is that the cookie value *may* be matching a session ID on the server side... so you may generate a cookie but it might be meaningless to the server.

On the other hand, if this is not the case, then a cookie value is a very simple name/value pair sent up to the server just like POST parameters. You can see an example of exactly how they must look by downloading the webRequest2 class in the php repository here - look at the function that builds the header - you'll see that the "cookie string" or the header containing cookies is pretty darn simple to construct. I am not sure, but I believe that cookies are set with a property or member function or something with cURL - it's not tough.
Logged

If I can't be Mr. Root then I don't want to play.
nattsurfaren
Journeyman
***
Offline Offline

Posts: 52


View Profile
« Reply #2 on: July 20, 2008, 06:02:06 PM »

Thanks for your response Smiley
I will check out your class. Praise
I read a bit more about cookies and there is also an Expires member that need to be considered I think.

/Natt
Logged
nutballs
Administrator
Lifer
*****
Online Online

Posts: 3456


View Profile
« Reply #3 on: July 20, 2008, 06:09:01 PM »

actually I dont think 'expires' is readable by the server? I think it is only set by the server. I could be wrong though. But anyway, even if it can, I doubt it is being read, since its actually for the browser to know when it can toss out the cookie.

if they are not matching any key info, then faking a cookie is the way to go. But most likely they are, since otherwise, really what is the point in a temporary cookie, but to track a user across transactions.
Logged
nop_90
Global Moderator
Lifer
*****
Offline Offline

Posts: 1141


View Profile
« Reply #4 on: July 20, 2008, 06:37:48 PM »

IMHO easiest to load the page first, do what u need to get the cookies etc.
It is only 1 page load, and if u enable gzip compression etc, uses very little BW.
Logged
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Online Online

Posts: 636



View Profile
« Reply #5 on: July 21, 2008, 05:36:26 AM »

Yeah, you can specify a header with cURL.

curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

or something like that.

I typically do it that way because it gives me more control than allowing a cookie file to just do all the storage.
Logged

perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 5230


:sniffle: Humor was so much easier before.


View Profile
« Reply #6 on: July 21, 2008, 08:50:18 AM »

expires is a value sent from the server to the client, so that it will be invalid after a certain period of time. I don't think it is passed back to the server.
Logged

If I can't be Mr. Root then I don't want to play.
nattsurfaren
Journeyman
***
Offline Offline

Posts: 52


View Profile
« Reply #7 on: July 21, 2008, 05:34:26 PM »

Thanks for your help.

BTW How do you deal with cookies and javascript. I'm a bit worried about that curl, webRequest2 or snoopy could get a different cookie than from a  browser that handle javascript. figure I could solve this to just insert the missing information along with the fetched cookie data.
I don't really know how I should handle this. Maybe there is method for reading and writing cookie members that I don't know of so that I don't have to figure out cookie.txt file.

Any help on this is most appreciated.

Sincerely
Natt
Logged
nutballs
Administrator
Lifer
*****
Online Online

Posts: 3456


View Profile
« Reply #8 on: July 21, 2008, 06:01:48 PM »

you want to get really worried, what about cookies that are requested via ajax, after the page has finished loading. 
Logged
nattsurfaren
Journeyman
***
Offline Offline

Posts: 52


View Profile
« Reply #9 on: July 22, 2008, 05:26:57 AM »

you want to get really worried, what about cookies that are requested via ajax, after the page has finished loading. 
Ajax can be Evil  Devilish
Logged
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!