web_master Posted June 2, 2007 Share Posted June 2, 2007 Hi, ive got an index file. In header is the srcipt for a send cookie to change languages. I have a 3 flags with a link to change language-cookie. Everything is woking fine except that I (user) must click 2 times on a flag to chage a language on site - because the first (reload) time cookie goes to browser and on second click read index file from browser. How can I do to language chage on one click? Thanx! Quote Link to comment https://forums.phpfreaks.com/topic/53992-language-cookie-and-refresh/ Share on other sites More sharing options...
breath18 Posted June 3, 2007 Share Posted June 3, 2007 so i follow, the user clicks on the link, the site then sets a cookie, but then does not read the cookie untill they refresh the page one More time ? Hopefully im on the right track, let me know Quote Link to comment https://forums.phpfreaks.com/topic/53992-language-cookie-and-refresh/#findComment-267308 Share on other sites More sharing options...
dsaba Posted June 3, 2007 Share Posted June 3, 2007 to use cookies just set you must reload the page, its that simple setup some if/else statements to accomodate for this, and make some method of immediately changing the language of the page based what is selected, if thats what you want check this out: http://tinyurl.com/2q8hsh I have a langcheck() function which changes the page language based on these priorities get['lang'] always takes preference sets it to that language if that is specified sets a cookie in the language if no get['lang'] isset then look for a cookie set it to the language specified in the cookie if none of those are set then sets a default english cookie and puts default english language Quote Link to comment https://forums.phpfreaks.com/topic/53992-language-cookie-and-refresh/#findComment-267325 Share on other sites More sharing options...
xpace Posted June 3, 2007 Share Posted June 3, 2007 check this : http://www.phpfreaks.com/forums/index.php/topic,143541.0.html that's how I've done it, and it works fine - only cookie checking doesn't work for some strange reason. Quote Link to comment https://forums.phpfreaks.com/topic/53992-language-cookie-and-refresh/#findComment-267395 Share on other sites More sharing options...
dsaba Posted June 3, 2007 Share Posted June 3, 2007 make note on my above method that I posted When a person changes languages the page reloads with GET['lang'] variable THAT is why the page changes language, the cookie is only used if a user comes back and there is no GET['lang'] var in the url if you want to solely use cookies, develop an algorithim to reload the page, when a language is selected and then read the language cookie Quote Link to comment https://forums.phpfreaks.com/topic/53992-language-cookie-and-refresh/#findComment-267430 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.