Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$_SESSION issues!!!

Status
Not open for further replies.

CliffLandin

Programmer
Nov 14, 2004
81
US
I am having a problem with session variables. I can't seem to consistently read them.

This how I declare the session variable:

session_start();
header("Cache-control: private");

$_SESSION['user'] = $user;

This is how I read the variable:

session_start();
header("Cache-control: private");
if (!isset($_SESSION['user']))
header("Location:else
$user=$_SESSION['user'];

Sometimes it works. Sometimes it doesn't. What am I doing wrong? It drives me crazy.

When in doubt, go flat out!

 
Try to add the SID (session id) at the end of the querystring.

Code:
<?=SID?>

the problem might be your firewall, etc. blocking the SID cookie.

Olav Alexander Mjelde
Admin & Webmaster
 
Are you sure that all pages have the session_start() as it seems a bit strange that it works sometimes and not others. I was wondering if the times that it didn’t work if you was going to the page via a different route? A route where there is no session_start() in one or more pages.

A problem with no solution is a problem viewed from the wrong angle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top