I'm trying to learn more about PHP sessions, as I'm going to be using them in a website I'm building soon.
Anyways, my problem with them is that I'm wondering how I can make them last after the user's browser is closed.
Here is a code example:
<?php
start_session();
$_SESSION['name']='Andrew';
$_SESSION['country']='Canada';
$_SESSION['age']=16;
?>
Then obviously I would view the session on another page with code like this:
<?php
start_session();
echo $_SESSION['name'];
//and so on
?>
Now, as I understand it... sessions are stored in a cookie on the user's browser so that other scripts can use them and such. The above code always works, and I can go to another page and come back and it still works. But, if I close my browser and I come back to the page that views the session variables, they aren't set anymore.
I've tried changing settings like session:cookie.lifetime, session:cookie.expire, etc. but so far, I've pretty much had no luck. I've searched with google thoroughly and checked the PHP manual, and I haven't found anything that's helped me out.
So, anyone have anything that'll help me out? Basically, I'm going to be using sessions with MySQL for authentication and such, so I figured it would be nice to have users logged in when they come back after closing their browsers. I assume this is possible, as I've seen it before, but perhaps the websites were using something different?