PHP Classes

Set-Cookie After Redirect

Recommend this page to a friend!

      PHP HTTP protocol client  >  All threads  >  Set-Cookie After Redirect  >  (Un) Subscribe thread alerts  
Subject:Set-Cookie After Redirect
Summary:Hoe get Set-Cookie values After Several Redirections
Messages:5
Author:Sultan
Date:2007-02-06 19:12:20
Update:2007-02-08 19:28:51
 

 


  1. Set-Cookie After Redirect   Reply   Report abuse  
Picture of Sultan Sultan - 2007-02-06 19:12:20
Hi!

$error=$http->SendRequest($arguments);
// After posting data to auth page I get this responce (several redirection)

HTTP/1.1 302
Set-Cookie: PHPSESSID=494dcc75841564affc2cf2e1c8a26ae0; expires=Thu, 01 Mar 2007 22:32:42 GMT; path=/
Location: http://**
Disconnected from saveoceanbeach.org
...
HTTP/1.1 302
Location: http://***
...
HTTP/1.1 302
Location: **
...
HTTP/1.1 200 OK
...

// To follow I need the values of Set-Cookie, but when I do
$error=$http->ReadReplyHeaders(&$headers);
print_r($headers);
// It give me only last responce heders (200 Ok and below)

[http/1.1 200 ok] =>
[date] => Tue, 06 Feb 2007 18:59:25 GMT
[server] => Apache/1.3.34 (Unix) mod_macro/1.1.2 mod_ssl/2.8.25 OpenSSL/0.9.7d
[x-powered-by] => PHP/4.4.0
[transfer-encoding] => chunked
[content-type] => text/html; charset=utf-8

How can I get values of set-cookies (and other headers, which are above last responce)?

Thank You

  2. Re: Set-Cookie After Redirect   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-02-07 22:27:42 - In reply to message 1 from Sultan
The headers you may get with the GetResponseHeaders function.

The cookies can be saved and restored from an array using the SaveCookies and RestoreCookies functions available in a version of the class that was just uploade.

  3. Re: Set-Cookie After Redirect   Reply   Report abuse  
Picture of Sultan Sultan - 2007-02-08 15:17:14 - In reply to message 2 from Manuel Lemos
Thank's very much!
Really good and quick job!!

>> The headers you may get with the GetResponseHeaders function.

ReadReplyHeaders , I think:)

Today, I noticed some bug (but not sure at all):
When I switch to
$http->protocol_version="1.0";

Command
$error=$http->ReadReplyBody($body,1000000);
return me only piece of page (about 1K)

and evrything ia ok, when I swith to default protocol version (1.0)


  4. Re: Set-Cookie After Redirect   Reply   Report abuse  
Picture of Sultan Sultan - 2007-02-08 15:19:24 - In reply to message 3 from Sultan
it's mistake in last line of my previous message

and evrything is ok, when I swith to default protocol version (1.1)

  5. Re: Set-Cookie After Redirect   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-02-08 19:28:51 - In reply to message 3 from Sultan
Do not use HTTP 1.0 unless you really have to. The problem is that HTTP 1.0 does not provide a means to know when the server has sent all the data of the HTTP response.

If the response headers do not contain any Content-Length information, the server may close the connection before the class could determine whether it has received all the data.