curl-and-php
Forwarding / Proxying Cookie
Date: Sun, 13 May 2007 23:08:25 +0200
Hi List,
i have this configuration
Server 2 [phpBB Forum]
Server 1 [PHP SERVER with CURL]
Localhost [Computer which makes call to Server 1]
Localhost --> browser page call --> server 1 --> login with php-curl --> server 2
server 2 --> sends cookie to --> server 1 --> forwards header to --> localhost
my code on server 1:
$this->curl = curl_init();
// Set options
curl_setopt ( $this->curl, CURLOPT_URL, $this->phpbb_url . 'login.php' );
curl_setopt ( $this->curl, CURLOPT_POST, true );
curl_setopt ( $this->curl, CURLOPT_POSTFIELDS, $post_fields );
curl_setopt ( $this->curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $this->curl, CURLOPT_HEADER, true );
curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, array(&$this,'readHeader'));
curl_setopt ( $this->curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
private function readHeader($ch, $header) {
$this->headers[] = $header;
return strlen($header);
}
.....
// $phpbb->getHeaders() contains $this->headers few lines above
foreach( $phpbb->getHeaders() as $line )
{
header( $line );
}
returned header is:
HTTP/1.1 302
Date: Sun, 13 May 2007 21:05:55 GMT
Server: Apache/2.0.54 (Debian GNU/Linux) mod_fastcgi/2.4.2
X-Powered-By: PHP/5.2.1-0.dotdeb.1
Set-Cookie: phpbb2mysql_data=a%3A0%3A%7B%7D; expires=Mon, 12-May-2008 21:05:55 GMT; path=/
Set-Cookie: phpbb2mysql_sid=dd48991ae02c4df3568ca0d1c9980b1f; path=/
Set-Cookie: phpbb2mysql_data=a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A0%3A%22%22%3Bs%3A6%3A%22userid%22%3Bs%3A5%3A%2214388%22%3B%7D; expires=Mon, 12-May-2008 21:05:55 GMT; path=/
Set-Cookie: phpbb2mysql_sid=5b05c3be3sfsafe5618esfsf9da3f09aa78; path=/
Set-Cookie: user_id=14391; expires=Mon, 12-May-2008 21:05:55 GMT; path=/
Set-Cookie: user_name=K3K; expires=Mon, 12-May-2008 21:05:55 GMT; path=/
Set-Cookie: user_pw=e5019dd1736adsdfasf44941c886577; expires=Mon, 12-May-2008 21:05:55 GMT; path=/
Set-Cookie: PHPKITSID=deleted; expires=Sat, 13-May-2006 21:05:54 GMT; path=/
Location: http://www.edited.xy/phpBB2/index.php?sid=5b05c3be3ff5e5618eb999da3f09aa78
Transfer-Encoding: chunked
Content-Type: text/html
.....
but for some reason it doesnt work....after the redirect im not logged on that site (the login mechanism works 100%). and cookie is set as well .. i tried to call var_dump( $_COOKIE ) before the header: location was called .. and it dumped me the correct key->values.
any idea, whats going wrong?
thanks you so much really for any help
regards
alex
-- Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten Browser-Versionen downloaden: http://www.gmx.net/de/go/browser _______________________________________________ http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-phpReceived on 2007-05-13