note 25246 added to ref.session
| From: | dave at talldave dot com | Date: | Mon, 16 Sep 2002 13:46:49 +0000 |
| Subject: | note 25246 added to ref.session | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-36752@lists.php.net to get a copy of this message | ||
I've noticed that when the session ID is propgated in GET mode, the SID string isn't added
to the URL when the first page that is loaded. This means that if refresh is hit for some reason a
new session starts. I have corrected this with the following code :-
session_start(); // Start the PHP Session
if (!isset($HTTP_COOKIE_VARS[session_name()]) && !isset($HTTP_GET_VARS[session_name()])) {
$PROTOCOL = ((isset($HTTPS) && $HTTPS == 'on')) ? "https" :
"http";
session_write_close();
header("Location: ". $PROTOCOL. "://".$HTTP_HOST.$PHP_SELF . "?"
. SID . (empty($HTTP_SERVER_VARS['QUERY_STRING']) ? "" : "&" .
$HTTP_SERVER_VARS['QUERY_STRING']));
}
--
http://www.php.net/manual/en/ref.session.php
http://master.php.net/manage/user-notes.php?action=edit+25246
http://master.php.net/manage/user-notes.php?action=delete+25246
http://master.php.net/manage/user-notes.php?action=reject+25246