Hello,

I use Wget version 1.10-alpha2+cvs-dev (because of the avalability of the --keep-session-cookies option).

I'm trying to wget a member page, where cookies are required for access.

The usual login procedure is:
-----------------------------
- Get a session cookie (PHPSESSID) on http://host.com/index.php
- Get http://host.com/checkuser.php which defines additional cookies. checkuser.php requires PHPSESSID, username, and password in POST method.
- The server responds with a "Location: http://host.com/member.php"; in headers. Here is the point : member.php requires cookies defined by index.php and checkuser.php. However these cookies are not resended by Wget. Thus I can't have access to member.php (for some reason, the download of member.php ends with a timeout when cookies aren't set).


Here is how I proceed:
----------------------
- Get the PHPSESSID
$ wget --cookies=on --keep-session-cookies --save-cookies=cookie.txt http://host.com/index.php
(I'm then getting the value of PHPSESSID in a variable with a cut -s -f 7 cookie.txt)
- Authenticate on http://host.com/checkuser.php
$ wget --referer='http://host.com/index.php' --cookies=on --load-cookies=cookie.txt --keep-session-cookies --save-cookies=cookie.txt --post-data='PHPSESSID=$phpsessid&username=$usr&password=$pwd' http://host.com/checkuser.php


Wget downloads and set the new cookies properly, on checkuser.php, then redirects on member.php but keep retrying and eventually ends with a timeout.

Considerations
--------------
I can see two ways to avoid this issue:
- Tell Wget not to follow links in "Location:" field in headers. I could then resend the cookies to member.php;
- Tell Wget to resend cookies when following links in headers.


I didn't find anything in the documentation about these work-arounds. How to resolve this problem?

Best regards,

Pierre



Reply via email to