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
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.