orange08 Posted September 23, 2009 Share Posted September 23, 2009 i know very little about session and want to know more... for session, i code session_start(); in every php file...is that this is the correct way to maintain the session? Quote Link to comment https://forums.phpfreaks.com/topic/175213-dealing-with-session/ Share on other sites More sharing options...
Alex Posted September 23, 2009 Share Posted September 23, 2009 Yes, and make sure that it's at the top of the file. Otherwise if there's any output before you call that you'll get a headers already sent error. Quote Link to comment https://forums.phpfreaks.com/topic/175213-dealing-with-session/#findComment-923482 Share on other sites More sharing options...
trq Posted September 23, 2009 Share Posted September 23, 2009 Yes. Quote Link to comment https://forums.phpfreaks.com/topic/175213-dealing-with-session/#findComment-923483 Share on other sites More sharing options...
PFMaBiSmAd Posted September 23, 2009 Share Posted September 23, 2009 In every php file... Only in those web pages that are setting or referencing a session variable. Quote Link to comment https://forums.phpfreaks.com/topic/175213-dealing-with-session/#findComment-923484 Share on other sites More sharing options...
orange08 Posted September 23, 2009 Author Share Posted September 23, 2009 ok, thanks! and if i need to regenerate session id for certain page, then i just code like below? session_start(); session_regenerate_id(); need to put session_start() in this case too, right? Quote Link to comment https://forums.phpfreaks.com/topic/175213-dealing-with-session/#findComment-923487 Share on other sites More sharing options...
orange08 Posted September 24, 2009 Author Share Posted September 24, 2009 ok, thanks! and if i need to regenerate session id for certain page, then i just code like below? session_start(); session_regenerate_id(); need to put session_start() in this case too, right? anyone can provide me the answer? Quote Link to comment https://forums.phpfreaks.com/topic/175213-dealing-with-session/#findComment-923933 Share on other sites More sharing options...
orange08 Posted September 25, 2009 Author Share Posted September 25, 2009 By default, the unique identifier that the server gives the browser is named PHPSESSID. This variable is stored on the client in either a URL, or a cookie. PHP first tries to set a cookie. If a browser does not accept cookies, PHP will append PHPSESSID to all URLs. i read about this in a tutorial... i would like to know if i disable my browser cookie, is that the session identifier will be automatically appended to my URL? i did try it with my application, but seem it doesn't append session identifier to my URL, but my function just fail because session can't be created... what's going on here? Quote Link to comment https://forums.phpfreaks.com/topic/175213-dealing-with-session/#findComment-924572 Share on other sites More sharing options...
trq Posted September 25, 2009 Share Posted September 25, 2009 There is a setting in your php.ini (session.use_only_cookies) that prevents sessions being used when cookies are disabled. This is now the default since 5.3, maybe you have it set to 1. Quote Link to comment https://forums.phpfreaks.com/topic/175213-dealing-with-session/#findComment-924579 Share on other sites More sharing options...
orange08 Posted September 25, 2009 Author Share Posted September 25, 2009 There is a setting in your php.ini (session.use_only_cookies) that prevents sessions being used when cookies are disabled. This is now the default since 5.3, maybe you have it set to 1. yup, i know about that...but without those setting, then session identifier should be appended to my URL if disable the cookie, right? but, from my testing...seem NOT... so, i don't know where's gone wrong and just worry if i didn't make it clear, latter the session identifier might be appended to URL without my knowledge... you meant set session.use_only_cookies as ON, then session won't be created if cookie is disable? Quote Link to comment https://forums.phpfreaks.com/topic/175213-dealing-with-session/#findComment-924587 Share on other sites More sharing options...
orange08 Posted September 28, 2009 Author Share Posted September 28, 2009 There is a setting in your php.ini (session.use_only_cookies) that prevents sessions being used when cookies are disabled. This is now the default since 5.3, maybe you have it set to 1. yup, i know about that...but without those setting, then session identifier should be appended to my URL if disable the cookie, right? but, from my testing...seem NOT... so, i don't know where's gone wrong and just worry if i didn't make it clear, latter the session identifier might be appended to URL without my knowledge... you meant set session.use_only_cookies as ON, then session won't be created if cookie is disable? help me, please! i have being stop here for about a week... :'( Quote Link to comment https://forums.phpfreaks.com/topic/175213-dealing-with-session/#findComment-926389 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.