codeline Posted August 23, 2010 Share Posted August 23, 2010 Not too familiar with sessions but I was curious to get others' input on this situation. I want to have users visit my site and be confronted with selecting their region, which will filter out the content they see. What type of sessions lifetime should I be working with here? I was thinking of keeping the session registered for as long as they stay on the site and maybe an hour afterwards just incase they visit again. Quote Link to comment https://forums.phpfreaks.com/topic/211459-sessions-for-region-selector/ Share on other sites More sharing options...
MadTechie Posted August 23, 2010 Share Posted August 23, 2010 might as well use a cookie! Quote Link to comment https://forums.phpfreaks.com/topic/211459-sessions-for-region-selector/#findComment-1102525 Share on other sites More sharing options...
codeline Posted August 23, 2010 Author Share Posted August 23, 2010 ah, so I should avoid the sessions and just deal the whole thing in cookies? Quote Link to comment https://forums.phpfreaks.com/topic/211459-sessions-for-region-selector/#findComment-1102529 Share on other sites More sharing options...
Garethp Posted August 23, 2010 Share Posted August 23, 2010 Honestly it's something that might be best suited for GeoLoction based on IP (If by region you mean country/state) but if you mean more specifics like city, I'd use a cookie for when they aren't registered, but have it stored in a database on registration so that people can use computers from different locations to see content relevant to where they want. As for avoiding sessions, in this case there doesn't seem to be any advantages or disadvantages to sessions OR cookies Quote Link to comment https://forums.phpfreaks.com/topic/211459-sessions-for-region-selector/#findComment-1102531 Share on other sites More sharing options...
codeline Posted August 23, 2010 Author Share Posted August 23, 2010 I actually only need to filter content for 2 countries, which makes things a bit easier for me. As far as cookies or sessions, I was more concerned about which would handle the length of time to hold the session or cookie better. Quote Link to comment https://forums.phpfreaks.com/topic/211459-sessions-for-region-selector/#findComment-1102534 Share on other sites More sharing options...
Namtip Posted August 23, 2010 Share Posted August 23, 2010 I actually only need to filter content for 2 countries, which makes things a bit easier for me. As far as cookies or sessions, I was more concerned about which would handle the length of time to hold the session or cookie better. I'm a newbie too, but he's my two cents. Sessions can last as long as you want them to until a user closes his or her browser (this will end the session even if the reopen the browser). Cookies will last as long as you want them to (even if they close their browser) but people might have cookies disabled in their browser. Hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/211459-sessions-for-region-selector/#findComment-1102547 Share on other sites More sharing options...
MadTechie Posted August 23, 2010 Share Posted August 23, 2010 I'm a newbie too, but he's my two cents. Sessions can last as long as you want them to until a user closes his or her browser (this will end the session even if the reopen the browser). Cookies will last as long as you want them to (even if they close their browser) but people might have cookies disabled in their browser. Hope that helps. Well said, Namtip this is the actual reason i suggested cookies Quote Link to comment https://forums.phpfreaks.com/topic/211459-sessions-for-region-selector/#findComment-1102549 Share on other sites More sharing options...
codeline Posted August 23, 2010 Author Share Posted August 23, 2010 MadTechie did you mean sessions since cookies can be disabled sometimes? Quote Link to comment https://forums.phpfreaks.com/topic/211459-sessions-for-region-selector/#findComment-1102557 Share on other sites More sharing options...
MadTechie Posted August 23, 2010 Share Posted August 23, 2010 while that's true the default set-up for sessions uses a cookie to store the session id, if cookies are disabled then your need to pass the session id via the URL, which seams pointless on a page that redirects! and also when you leave the site and re-enter the link to the session id would be lost, so if cookies are disabled then sessions won't provide much of a solution either! Quote Link to comment https://forums.phpfreaks.com/topic/211459-sessions-for-region-selector/#findComment-1102559 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.