| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| Senior Member | 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) |
| Stud Sausage | 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 |
| |
| | #3 (permalink) |
| Senior Member | 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. |
| |
| | #5 (permalink) |
| Senior Member | 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 | Quote:
__________________ Buy now - MassDeveloper.com $500 | |
| |
| | #7 (permalink) |
| NamePros Regular | 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. 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'); |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |