stevesimo Posted March 21, 2007 Share Posted March 21, 2007 Hi, I am attempting to create a login in script using a session variable to hold the user id. I have got the log in facility working. Just before I redirect the user I set the session variable to the ID. Then when I get to the next page I check to see if the session exists, if it does then I output it. The only problem is that instead of outputting the ID I keep getting 'Session ID: Resource id #7' Here is my code: //set session to ID $session['BrokerID'] = '123456'; //redirect the user to the bike policy admin page echo "<meta http-equiv=\"refresh\" content=\"2;URL=bikepolicyadmin.php?id=$row->id\">"; ********************** THEN ON THE REDIRECT PAGE ********************** session_start(); if(isset($_SESSION['BrokerID'])) $result = $_SESSION['BrokerID']; else $result = 'no session exists'; echo 'Session ID: '.$result; The ID is passed in the query string successfully but when I try and set an ID value in the session it doesn't work. Can anyone see what I am doing wrong? Many thanks Steve (Blackpool) Link to comment https://forums.phpfreaks.com/topic/43641-solved-session-not-storing-id/ Share on other sites More sharing options...
vbnullchar Posted March 21, 2007 Share Posted March 21, 2007 place session_start() on this page too session_start(); //set session to ID $session['BrokerID'] = '123456'; //redirect the user to the bike policy admin page echo "<meta http-equiv=\"refresh\" content=\"2;URL=bikepolicyadmin.php?id=$row->id\">"; Link to comment https://forums.phpfreaks.com/topic/43641-solved-session-not-storing-id/#findComment-211902 Share on other sites More sharing options...
per1os Posted March 21, 2007 Share Posted March 21, 2007 Shouldn't you use this also: //set session to ID $_SESSION['BrokerID'] = '123456'; //redirect the user to the bike policy admin page echo "<meta http-equiv=\"refresh\" content=\"2;URL=bikepolicyadmin.php?id=$row->id\">"; Link to comment https://forums.phpfreaks.com/topic/43641-solved-session-not-storing-id/#findComment-211945 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.