I am writing a Bash script to connect to OpenCart's admin section and do something in there (for example, add a product). The script looks something like this:
wget --save-cookies=cookies.txt --keep-session-cookies --post-data 'username=admin&password=abcdefg' -O login-response.html "http://mysite.com/admin/index.php?route=common/login"
# Get the token out of the login-response file.
token=`awk '/token=/ {print $0}' login-response.html | sed -n '/.*token=[0123456789abcdef]\+.*/{p;q;}' | sed 's/.*token=\([0123456789abcdef]\+\).*/\1/'`
echo Token1= $token
wget --load-cookies=cookies.txt -O page-response.html "http://mysite.com/admin/index.php?route ... ken=$token[/b]"
# Get the token out of the page-response file.
token=`awk '/token=/ {print $0}' page-response.html | sed -n '/.*token=[0123456789abcdef]\+.*/{p;q;}' | sed 's/.*token=\([0123456789abcdef]\+\).*/\1/'`
echo Token2= $token
Token1 and Token2 match. But the "page-response.html" is a page that says "Invalid token session. Please login again." I've checked the cookie file and the PHPSESSID is there and seems to be correct...
Any idea why my sessions are invalid? (I can login fine from my browser.)
Who is online
Users browsing this forum: No registered users and 31 guests