Jump to content

Carrying the session on


smc

Recommended Posts

Hello,

I have googled and checked the manual but I just can't find anything I understand that relates to what I'm doing.

Basically I have my login script. They login and it starts a session. Here is my session code:

[code=php:0]
else{
//We will now start our session
session_start();
//Now we are going to assign all that information we retrieved from our database to our session so it can be used later
$_SESSION['username'] = $sqlusername;
$_SESSION['password'] = $sqlpassword;
$_SESSION['firstname'] = $sqlfirstname;
$_SESSION['lastname'] = $sqllastname;
$_SESSION['position'] = $sqlposition;
$_SESSION['rank'] = $sqlrank;
$_SESSION['email'] = $sqlemail;
[/code]

Now it works when the page reloads and displays the session username in a string. But my problem lies when trying to go to a different page.

I placed a link to an "admin panel" on the login success page. This admin panel page checks the SESSION 'rank' and sees if it matches "admin" if it doesn't it shows an error page.

I just keep getting the error page, which leads me to believe the session is broken after the link is visited (link opens in same window).

How do I go about continuing the session until the browser closes or they click a button that does a session_destroy(); function?

Thanks!!!
Link to comment
https://forums.phpfreaks.com/topic/35141-carrying-the-session-on/
Share on other sites

You don't, that's the point of sessions. You'd have to move the info into cookies.

Edit: well maybe not the point, but how they work. Sessions last only for the browser session - session meaning period of use. If you close the browser or kill the session, it's gone.

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.