Problem with wget and cookie

Dear people, I got a problem with an scrip using wget to download pdf-files from an website which uses session-cookies.

Background: for university its quite nasty to look up weekly which new homeworks, papers etc. are available on the different sites of the universites chairs. So I wanted a script which download the homepage with all the links (wget), use sed to get the links and names of the dokuments out of the html page, and download the different documents with wget to the seperate folders.

Problem now: one website uses session cookies, you have to re-enter the Password every time (I think the cookie expires every day). thats my code to get the cookie:

#!/bin/sh

# Log in to the server.  This can be done only once.
          wget --save-cookies cookies.txt \
               --post-data 'successRedirect=http%3A%2F%2Fwww.xxxxxxxxxxxxxx.de%2F%2Ffile.php%3Fid%3D20745%26l%3D1%26&usrName=XXXX&usrPass=XXXXX&login=Anmelden' \
        --keep-session-cookies \
               http://www.xxxxxxxxxxxxxx.de//index.php?id=20745&o=18059&_f=20745&l=1&_action=login

I dont want to post the Page and password here public, if neccesary I can post the page, but maybe we can fix the problem without.

So I get out of this the cookie

# HTTP cookie file.
# Generated by Wget on 2012-06-21 22:26:04.
# Edit at your own risk.

www.xxxxxxxxx.de    FALSE    /    FALSE    0    PHPSESSID    cc124cb622ffa9fd60f288a68db3e597

I bet its a md5 sum including a timestamp.

Then I try to use the cookie.txt to download a file:

# Now grab the page or pages we care about.
          wget --load-cookies cookies.txt \
               -p http://www.xxxxxxxx.de//file.php?id=20745

Problem, I only get redirekted to another page like when you entered a wrong password in the Browser (Firefox) and so would have got a wrong cookie/md5-sum.

Password is correct. When I readout the cookie out of firefox and copy and paste the md5-sum which is stored by firefox, it works perfectly! so my request for the cookie must be wrong.

On the website, the checking of username and Password is a normal html-form. I used firebug to edit the submit-part with "mailto:...." to be sure to get the correct strig which will be submitted by the browser. But entering this string into my shell-script to get wget to download the cookie didnt work.....(it generates two different md5-sum, thats why I estimate a time stamp is included :), and otherwise a session-cookie wouldnt make sense. )

Ok, now has anybody an idea what do I do wrong?
Is there anything else helpful I can post you?
Its not an super-urgent matter, but it bothers me :slight_smile:
thank you in advance!
jackomo

mhm, ideas :)?