Jump to content

making sessions last longer?


MrAdam

Recommended Posts

I only use<?phpsession_start();?>on top of all my sites (well, only index.php since I use the GET method in the URL address), and if I haven't been at the logout page where I have <?php session_start(); session_destroy(); ?> it survives...it did last time I accidentely closed my Web site where I'm making my own CMS where I use that log in script that works fine.

Link to comment
Share on other sites

Every thing depends on how long you are out of the site, if you login to a site then close the browser and open after 2minutes, then you should be able to use this code to get back in dont know if it is possible to have it longer, without useing cookies.well if you want to test :

if(isset($_SESSION['username'])){header("Location: home.php");exit();}

but if you want to have it last even longer i dont know...->Kristian_C.

Link to comment
Share on other sites

i think it depends on the configuration of sessions. what i want is so that people can do stuff on the webpage with their session; exit the browser; upto a day later return to the website and it have saved their session. So anything they add to the shopping cart for example, will still be there up to a day later ..

Link to comment
Share on other sites

I know how to use cookies - i think the problem is that the sessions simply won't last a day without having access to the php.ini file. I think the best way to do it would be to save their session data in a database. if anyone thinks otherwise though, please le'me know !-cheerrs!

Link to comment
Share on other sites

How can i make a session survive after closing the browser?
You can't. That's what a session is, it is the connection information for a connection between a client and server. When you close and reopen the browser, you create a new connection with a new session. You can't reuse the same connection, it is already closed.Any site you see that retains information when you come back is using cookies. They might use their own sessions, such as saving some sort of session ID in a cookie and using their own database to keep track of their own sessions, independent of the web server's session handling. So they would keep the shopping cart information in a database, associated with a certain session ID, the browser comes back and sends the cookie with their session ID in it and they look up everything in their own session database. But from a technical perspective they are still using a new connection with a new web server session, it just so happens that the web site is using custom sessions instead of the web server's internal sessions.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...