0

Hi, I am trying to create a website where the visitor can choose one of two languages when first arriving at the website. Then I want that choice to be saved throughout the whole visit without the visitor having to log in. I've always felt that cookies are a lame way of solving things so first I tried out always including the language choice in the url and making sure that the language choice always remained (if not the user switched it) through variables and php redirects if the choice was removed from the url. But it too felt unprofessional so I tried out storing the information in a session and it works perfectly except that I'm trying to create a script that deletes the session variable when the user leaves the site (onunload on the body doesn't work here because then it gets executed when the user wants to view another page of the site and not just when he leaves).

Maybe this is all unnecessary and I should just go with a cookie? Or does anyone have another solution?

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by gunnarflax
0

Hi, I am trying to create a website where the visitor can choose one of two languages when first arriving at the website. Then I want that choice to be saved throughout the whole visit without the visitor having to log in. I've always felt that cookies are a lame way of solving things so first I tried out always including the language choice in the url and making sure that the language choice always remained (if not the user switched it) through variables and php redirects if the choice was removed from the url. But it too felt unprofessional so I tried out storing the information in a session and it works perfectly except that I'm trying to create a script that deletes the session variable when the user leaves the site (onunload on the body doesn't work here because then it gets executed when the user wants to view another page of the site and not just when he leaves).

Maybe this is all unnecessary and I should just go with a cookie? Or does anyone have another solution?

Sessions still use cookies. That's how the session data structure in the server's memory is mapped to the user's machine. Here's more on the topic from a daniweb user: http://www.daniweb.com/forums/thread138791.html

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.