Jump to content

[SOLVED] Session Not Storing ID


stevesimo

Recommended Posts

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

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\">";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.