Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/53992-language-cookie-and-refresh/
Share on other sites

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.