troubleshooting session expired using libcurl
|September 13, 2014||Posted by forumadmin under TechQns||
I am trying to login to a website using libcurl in c (http website, not https). The problem is that after the login if I try to reach a page in the domain I get redirected to a page claiming my session has expired and I need to relog.
I then assumed there must be a problem with the session cookie that the website uses. This is the code I use to handle the cookie. I use these settings at my very first request when I go to the login page.
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "cookie.txt"); curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "cookie.txt"); curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1);
I then used CURLOPT_VERBOSE to get information about the session. It seems I indeed receive a cookie and send it again in subsequent requests.
Set-Cookie: PHPSESSID=2d952576829405ce0d25689804b525ec; path=/
this cookie is also used in following requests like this:
finally when I go to cookie.txt I also see the cookie there:
domain FALSE / FALSE 0 PHPSESSID 2d952576829405ce0d25689804b525ec
So to conclude my question is: how can I further troubleshoot the issue of the expired session? Most sources on the internet explain how to get the cookie to work but in this case I don’t see a problem with the cookie.
|Asked By – Jasper||Read Answers|
More Related Questions
- logon and then access another page with the same session cookies using curl I looked at different seemingly similar questions but can't seem to understand it and also can't get it to work at all. Situation: I have an external website from where I can download […]
- Persistent/keepalive HTTP with the PHP Curl library? I'm using a simple PHP library to add documents to a SOLR index, via HTTP. There are 3 servers involved, currently: The PHP box running the indexing job A database box holding the […]
- Login and purchase system implemented by 2 servers I'm upgrading an old system. This is how the system works now (the system works in a non conventional way due to some limitation of old systems and databases): A user connects to […]
- PHP cURL can not keep session alive in remote site from live server My site is www.xyz.com. From my site I want to login in a remote site(for example: www.newxyz.com/index.php). And then I want to get data from another page (for example: […]
- Building libcurl with SSL support on Windows I'm using libcurl in a Win32 C++ application. I have the curllib.vcproj project added to my solution and set my other projects to depend on it. How do I build it with SSL support […]
- Run cURL command every 5 seconds This is the command that I want to run - curl --request POST --data-binary @payload.txt --header "carriots.apiKey:XXXXXXXXXXXXXXXXXXXX" --verbose http://api.carriots.com/streams This […]
- Can cookies be set from 4xx responses? I just tried setting (actually, deleting - via max age set to 0) a session cookie, when I detect a specific client error. The HTTP response I am using is from the 4xx category (e.g. 401, […]
- How do browser cookie domains work? Due to weird domain/subdomain cookie issues that I'm getting, I'd like to know how browsers handle cookies. If they do it in different ways, it would also be nice to know the […]