Jump to content

My computer has a mind of its own...


Rifts

Recommended Posts

I have used sessions before I don't know whats going on.

 

My sessions wont die.

 

this is what im doing:

 

<?php
session_start();

$_SESSION['user'] = $_POST['email'];
$_SESSION['pass'] = $_POST['pass'];

?>

 

ok new page

 

<?php
session_start();

echo $_SESSION['user'];
echo "<br>";
echo $_SESSION['pass']
?>

 

OK great is show the same info but now if I close my browser and go back to the second page where it echos it still shows the user//pass

I have tried restarting and it still saves the dam session!

 

Should it kill the session if i close my browser?

 

wtf?

 

Link to comment
Share on other sites

It depends on the session.cookie_lifetime setting (assuming that you are passing the session id using a cookie) or if you are passing the session id on the end of the URL and you are using a URL that contains the session id when you revisit the second page after opening your browser.

Link to comment
Share on other sites

Assuming you haven't overridden any settings, sessions are stored in a temporary file on your server's file system.

 

The session file is named after the user's session ID, which is stored either (a) in the user's PHPSESSID cookie, or (b) in the URL.

 

When the user visits the site, his cookie/URL are analyzed and the proper file is loaded into memory as $_SESSION.

 

Check the URL you're using.  If there's a 32-character hexadecimal code there that you don't recognize, it's your session ID, and anyone who uses that URL will get the same session as you.  This is why URL-based sessions are frowned upon and rarely used.

 

If there's no session ID in the URL, then you have a cookie called PHPSESSID on your browser.  It SHOULD be deleted once all your browser windows are closed, but it won't necessarily.  You'll have to delete the cookie by hand to clear your session.

 

-Dan

Link to comment
Share on other sites

well i fixed it and i dont understand why this worked...

 

instead of setting the session like this:

 

  $_SESSION['user'] = $_POST['email'];

 

I did

 

$email = $_POST['email'];

$_SESSION['user'] = $email

 

and now everything works fine... weird huh?

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.