header() and passing sessions
| From: | Adam Williams | Date: | Wed, 15 Apr 2009 16:09:19 +0000 |
| Subject: | header() and passing sessions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-291526@lists.php.net to get a copy of this message | ||
I need some help passing a session variable with a header() function. According to www.php.net/header, the documentation states:
*Note*: Session ID is not passed with Location header even if session.use_trans_sid <session.configuration.php#ini.session.use-trans-sid> is enabled. It must by passed manually using *SID* constant.
so, I'm trying to manually pass the SID, but not having any luck. Here is a snippet of my code:
There is a file login.php which has session_start(); and sets $_SESSION["username"] with the username you logged in with from index.php and has a form to click View Pending Requests which has the action of option.php.
-- option.php --
<?php
session_start();
if ($_POST["option"] == "View Pending Requests")
{
header('Location: http://intra.mdah.state.ms.us/helpdesk/viewpending.php?PHPSESSID='.session_id());
}
?>
--viewpending.php --
<?php
session_start();
if (!$_SESSION["username"])
{
echo "You have not logged in";
exit;
}
?>
so you click on View Pending Requests, and the URL in your browser is:
http://intra.mdah.state.ms.us/helpdesk/viewpending.php?PHPSESSID=du75p41hel9k1vpuah799l2ce7
but viewpending.php says "You have not logged in". Why is that?