pneudralics Posted April 29, 2009 Share Posted April 29, 2009 1) Session is not a cookie and a session is stored in a temporary server folder somewhere. Am I correct? 2) For a website that have users..is it better to use sessions or cookies? 3) How long does a session last by default if the user doesn't logout? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/156152-few-newbie-questions-about-sessions/ Share on other sites More sharing options...
mattal999 Posted April 29, 2009 Share Posted April 29, 2009 1) On the server (Somewhere...). 2) Cookies. 3) When browser closes I think. Possibly even on page close (Have to check that one with someone else). Quote Link to comment https://forums.phpfreaks.com/topic/156152-few-newbie-questions-about-sessions/#findComment-822003 Share on other sites More sharing options...
revraz Posted April 29, 2009 Share Posted April 29, 2009 1 On the Server, the sessions are stored in the session save path as defined in the php.ini file 2 That depends on what you want to do 3 Read the php.ini file under the Session key to learn about how often the GC runs and the modifier that goes with it. Quote Link to comment https://forums.phpfreaks.com/topic/156152-few-newbie-questions-about-sessions/#findComment-822005 Share on other sites More sharing options...
radi8 Posted April 29, 2009 Share Posted April 29, 2009 1. sort of correct... session values are stored in active memory 2. both... session data is for active content that will get flushed when user closes session or browser, cookies are used when you want to save information between user sessions 3. depends on the PHP.INI file setting, mine is set to: session.cache_expire = 180 minutes Quote Link to comment https://forums.phpfreaks.com/topic/156152-few-newbie-questions-about-sessions/#findComment-822006 Share on other sites More sharing options...
ignace Posted April 29, 2009 Share Posted April 29, 2009 1) Correct read revraz comment for more on this 2) Generally yes but it depends on what you want to store 3) Until the browser is closed. Check for more information: http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime You can extend the lifetime of a cookie by altering it's settings through: http://be2.php.net/manual/en/function.session-set-cookie-params.php don't go with the information that mattal999 provides you cookies aren't the kind of resource you want to use as storage between requests as cookies are easy to create and modify sessions aren't really save either but they provide an extra layer of security Quote Link to comment https://forums.phpfreaks.com/topic/156152-few-newbie-questions-about-sessions/#findComment-822008 Share on other sites More sharing options...
pneudralics Posted April 29, 2009 Author Share Posted April 29, 2009 Thanks for all the info. How do I prevent the session from automatically deleting when I close the browser? Quote Link to comment https://forums.phpfreaks.com/topic/156152-few-newbie-questions-about-sessions/#findComment-822070 Share on other sites More sharing options...
revraz Posted April 29, 2009 Share Posted April 29, 2009 It doesn't automatically delete per say, it is still on the server, but your browser would start a new one when you re-open it. You could store the session id in a db if you really wanted to. Quote Link to comment https://forums.phpfreaks.com/topic/156152-few-newbie-questions-about-sessions/#findComment-822074 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.