Jump to content

Sessions for Region Selector


codeline

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/211459-sessions-for-region-selector/
Share on other sites

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

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.

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

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.