PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am trying to come up with a good way to change between languagues without the website changing. Like... the user is viewing a certain thing on the site and wants to change languages. Navigation is done through GET so I made this quick function
But what happens if the user changes from english to estonian to finnish then tries to hit the back button? Problems thats what! Basically I need a non-javascript way to change the language the user is browsing in (stored in a session) without affecting their browsing expierence.
Is it because they'd go from Finnish back to English again?
I guess that is a small problem, but I emphasize small...
Your going to need to refresh the page in order to make language changes so the back button will always be a problem.
Unless you use AJAX to change the language or if there is some way to tell the browser not to cache a refresh in it's history???
Look into HTTP headers, perhaps there is something in there you could use, to at least expire previous pages so when you hit back you get an error instead of English???
Maybe there is a Javascript function which lets you change URL's and prevent caching?
Or you could use a landing/splash page which makes people pick a language before even browsing the site?
I use an intermediate page which will accept the url paramter of which language to use, and then redirect.. so if they do for some reason hit the back button they are simply redirected back to the page (although this time no processing is done).
let assume im browsing in english. I am looking at someones profile and everythings in english of course. Now I want to view that page in Estonian, then in Finnish. I am now viewing in Finnish but I want to go back to the profile I was viewing before this one I am currently on. Now I go back one and I am viewing in estonian, same profile (this should go back to the other profile instead of this one!). I go back again and finally I am back to the other profile but in Estonian (Should be in finnish since that was the last language I chose).
Understand? I don't know very many headers so if someone knows of one that might be able to help me here that would be fantastic unless someone has another idea (please no javascript)
EDIT:
Jcart wrote:I use an intermediate page which will accept the url paramter of which language to use, and then redirect.. so if they do for some reason hit the back button they are simply redirected back to the page (although this time no processing is done).
How do you get the entire current URL that the user is on? I may be one index.php, view.php, ... How would I make it find out which page to redirect to?
and for some odd reason when I change the $_SESSION['lang'] it does not save as it goes to another page. I dump($_SESSION) after setting it but before the header and I get:
[lang] => est
and after the header I do dump($_SESSION) and get: