simon551 Posted June 22, 2007 Share Posted June 22, 2007 Hi, I'm trying to work with a session variable from an include file in my page. I'm getting some unexpected results and I can't quite figure it out. <?php //if there is no session and no get, then default $cLId=-1; //if there is a session then grab it if(isset($_SESSION['cLId'])) { $cLId = $_SESSION['cLId']; } //if this is the starting page, reset or create the session, plus the variable if(isset($_GET['cLId'])) { $cLId = $_GET['cLId']; // create the session id to follow the cLId $_SESSION['cLId']=$cLId; } If I do this: echo $cLId; echo $_SESSION['cLId']; on a page with a "GET" of cLId = 25 it prints out 2525 which is great. But then if I do it on a page that includes the same variable function but doesn't have a 'GET' in it (just trying to utilize the SESSION) This: echo $cLId; echo $_SESSION['cLId']; Gives me -1 So it looks like the function I wrote doesn't take the session. Any idea what I'm doing wrong? Link to comment https://forums.phpfreaks.com/topic/56635-solved-session-problem/ Share on other sites More sharing options...
teng84 Posted June 22, 2007 Share Posted June 22, 2007 did u use the session start ASTIG!! Link to comment https://forums.phpfreaks.com/topic/56635-solved-session-problem/#findComment-279699 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.