Wget save cookies not working

Posted by TrymBeast on Super User See other posts from Super User or by TrymBeast
Published on 2012-06-23T21:48:49Z Indexed on 2012/06/24 9:18 UTC
Read the original article Hit count: 351

Filed under:
|
|
|

I've been trying to login in the pyload through the web api, but wget is not saving the cookies and I don't understand why.

I'm using the following command:

wget --delete-after --keep-session-cookies --save-cookies=my_cookies.txt --post-data="username=USERNAME&password=PASSWORD" http://localhost:8000/api/login

But the content of my_cookies.txt is:

# HTTP cookie file.
# Generated by Wget on 2012-06-23 22:31:33.
# Edit at your own risk.

When I run the same command but in debug mode I get the following output that includes the set cookie in the header response:

DEBUG output created by Wget 1.10.2 (Red Hat modified) on linux-gnueabi.

--22:31:11--  http://localhost:8000/api/login
Resolving localhost... 127.0.0.1
Caching localhost => 127.0.0.1
Connecting to localhost|127.0.0.1|:8000... connected.
Created socket 3.
Releasing 0x000504d0 (new refcount 1).

---request begin---
POST /api/login HTTP/1.0
User-Agent: Wget/1.10.2 (Red Hat modified)
Accept: */*
Host: localhost:8000
Connection: Keep-Alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 32

---request end---
[POST data: username=USERNAME&password=PASSWORD]
HTTP request sent, awaiting response...
---response begin---
HTTP/1.1 200 OK
Content-Length: 34
Content-Type: application/json
Cache-Control: no-cache, must-revalidate
Set-cookie:  beaker.session.id=405390ddc809efed54820638c95d7997; expires=Tue, 19-Jan-2038 04:14:07 GMT; Path=/
Connection: Keep-Alive
Date: Sat, 23 Jun 2012 21:31:11 GMT
Server: CherryPy/3.1.2 WSGI Server

---response end---
200 OK
hs->local_file is: login (not existing)
Registered socket 3 for persistent reuse.
TEXTHTML is on.
Length: 34 [application/json]
Saving to: `login'

100%[=======================================>] 34          --.-K/s   in 0s

22:31:11 (1.28 MB/s) - `login' saved [34/34]

Removing file due to --delete-after in main():
Removing login.
Saving cookies to my_cookies.txt.
Done saving cookies.

Can anyone tell me what am I doing wrong?

Thanks in advance!

© Super User or respective owner

Related posts about linux

Related posts about nas