| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Senior Member Join Date: Nov 2005 Location: on a oil rig just off Ireland
Posts: 1,408
![]() ![]() ![]() ![]() ![]() | Cookies on file_get_contents or cURL? Hi, I need to load up a page, but to view the page you need to be logged in (ie have cookies set). How do I set cookies in a php script so when I use file_get_contents() or cURL (don't know much about cURL) it loads the logged-in page rather than the login page? Hope I made myself clear.. please say if you don't understand. Thanks Colin
__________________ You design in photoshop, I code into valid XHTML/CSS. Professional PSD, PNG or HTML to tableless XHTML/CSS designs. For more info, send me a PM. |
| |
| | #2 (permalink) |
| Senior Member Join Date: Dec 2006 Location: England
Posts: 1,568
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | I do not know much about cURL i confess, as i have not used it before. However with cURL you can virtually submit forms and return the data from that. Cookies will be stored in turn with that. These may be more helpful than i can be right now: http://www.wagerank.com/2007/how-to-...orms-with-php/ http://www.google.co.uk/search?hl=en...e+Search&meta= Matt |
| |
| | THREAD STARTER #3 (permalink) |
| Senior Member Join Date: Nov 2005 Location: on a oil rig just off Ireland
Posts: 1,408
![]() ![]() ![]() ![]() ![]() | You think that'd work like that, would it store the cookies on the server?
__________________ You design in photoshop, I code into valid XHTML/CSS. Professional PSD, PNG or HTML to tableless XHTML/CSS designs. For more info, send me a PM. |
| |
| | THREAD STARTER #5 (permalink) |
| Senior Member Join Date: Nov 2005 Location: on a oil rig just off Ireland
Posts: 1,408
![]() ![]() ![]() ![]() ![]() | So something like this should work? PHP Code:
__________________ You design in photoshop, I code into valid XHTML/CSS. Professional PSD, PNG or HTML to tableless XHTML/CSS designs. For more info, send me a PM. |
| |
| | #6 (permalink) | ||||
| Domains my Dominion Join Date: Aug 2005 Location: Web 1.0
Posts: 9,552
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
__________________ NameNewsletter.com - free lists of available domain names ZoneFiles.net (beta) - ccTLD and gTLD droplists | ||||
| |
| | #7 (permalink) |
| Forum Moderator ![]() Join Date: Aug 2006 Location: USA
Posts: 2,037
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | CURLOPT_COOKIEJAR is used when you fetch a page that sets cookies. It declares a name of a file in which the cookies will be stored. ????: NamePros.com http://www.namepros.com/showthread.php?t=301397 Then you use that filename with CURLOPT_COOKIEFILE on subsequent requests to tell cURL to send the cookies in that file along with your request(s). For security reasons, be really careful where you keep the cookiejar file - unless there's a reason to keep it, delete it when you're done! If you just need to send a couple of cookies and you know what they are, you can use CURLOPT_COOKIE followed by a comma and a string (in single quotes) containing comma-delimited cookies and values. For example: curl_setopt($c, CURLOPT_COOKIE, 'cookie1=value1, cookie2=value2, cookie3=value3'); |
| |