nitrogenhurricane
nitrogenhurricane

Reputation: 301

Post data with curl (php) and then get sessionid from GET

So here is my problem: I want to login to a website using curl, and I send the login credentials with POST. However, after the successful login, I get redirected to a url, where my sessionid is passed with GET (and not in the cookies, so no way to get them from there). I would need that sessionid to access to the protected pages. So, how do I get it?

Any help is really appreciated.

Upvotes: 0

Views: 2885

Answers (2)

Joseph Lust
Joseph Lust

Reputation: 19985

$sessionId = parse_url( curl_getinfo($ch, CURLINFO_EFFECTIVE_URL) )['sessionId'];

Change 'sessionId' to the token name being used.

Upvotes: 0

goat
goat

Reputation: 31813

$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);

and then follow with parse_url() and then parse_str()

Upvotes: 1

Related Questions