note 11476 added to session_set_cookie_params

From: Date: Thu, 22 Feb 2001 04:33:35 +0000
Subject: note 11476 added to session_set_cookie_params
Groups: php.notes 
Request: Send a blank email to php-notes+get-11392@lists.php.net to get a copy of this message
ok. hope this works. first time posting heres a quick little snippet I came up with to pass sessions between lots of sub domains or c names. it also contains an array walker for reading and outputting the contents of the current array(in this case i use it for http_session_vars) ex: www.fluidideas.com chat.fluidideas.com mypage.fluidideas.com www.mypage.fluidideas.com these will all have access to the session. !!!BEGIN CUT!!! session_set_cookie_params ( time()+9999999 , "" , ".fluidideas.com" ); if ( $HTTP_COOKIE_VARS[session_id_set] ) { session_id( $HTTP_COOKIE_VARS[session_id_set] ); } session_start (); Function session_walker($Array) { If ( !Is_Array($Array) ) Return $Array; Reset($Array); While( List( $Key, $Value ) = Each( $Array ) ) { If ( Is_Array( $Array[ $Key ] ) ) { $Array[ $Key ] = session_walker( $Array[ $Key ] ); } Else { echo "key -> " . $Key . "<br>\n"; echo "value -> " . $Value . "<br>\n"; } } Return $Array; } !!!END CUT FOR SESSION INCLUDE!!! !!!BEGIN CUT!!! $user_session_id = session_id(); setcookie("session_id_set","$user_session_id",time()+9999999,"", ".fluidideas.com", ""); session_register("user"); session_register("password"); session_register("email"); !!!END CUT FOR LOGIN!!! now this example will allow the session to carry the data from sub domain to sub domain and it only has one flaw that i've noticed. NS 4.7 is the only browser I've seen this in (also use mozilla .8 and IE5.5) but if the domain doesnt contain a c name the sessions wont pass. ex: fluidideas.com not www.fluidideas.com If someone can come up with a fix to this please email me. Thanks http://www.php.net/manual/en/function.session-set-cookie-params.php

« previous php.notes (#11392) next »