note 106462 deleted from session.idpassing by danbrown

From: Date: Tue, 15 Nov 2011 16:32:50 +0000
Subject: note 106462 deleted from session.idpassing by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-184485@lists.php.net to get a copy of this message
Note Submitter: steve at stevelockwood dot net ---- a dot nielsen at shikadi dot net points out that the PHPSESSID needs to be the first parameter in the URL. This is a problem if your web server has a rewrite script which is doing some conversion on the URL, eg converting http://mysite/action to http://mysite?q=action. This can frustrate any attempts to put the PHPSESSID as the first parameter. A fairly simple solution is to use session_set_save_handler() to define your own session handling routine. You can define the session id in the custom open() routine as follows: <?php function open($save_path, $session_name) { // use session id given in URL if (isset($_REQUEST[$session_name])) { session_id($_REQUEST[$session_name]); } return true; } ?> With the above method it does not matter if PHPSESSID is not the first parameter. Obviously you also need to define the read(), write() and other session handling routines but this is well documented under session_set_save_handler(). You also need to make sure that all URLs referening content within your site contain the session ID by appending the SID constant.

« previous php.notes (#184485) next »