Welcome to WebmasterWorld Guest from 54.198.108.19

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Cookies not saving on certain machines

     
8:33 am on Aug 12, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:June 26, 2008
posts:178
votes: 0


Hi All,

I not long back launched a new multi-lingual website for our business. I did thorough testing before it's launch, however, after another branch in the business had some new machines installed, their website is not remembering their language settings.

They have a Spanish IP address so there website renders in Spanish. But when the staff set their language to English the browser will forget their preference upon close.

The older machines within the branch will remember the cookies as normal. But these new ones are presenting a problem.

I tried altering the browser settings in IE and Firefox and I even downloaded Chrome to try that.

Nothing.

My iPhone on their IP has no issues remembering the language.

Just these new machines...

Is it at client level, or is there any way this could be an issue with my coding?

My PHP code is as follows (I've removed a lot of repeating ifs - but the code is mainly the same):


<?
// THIS PAGE ASSIGNS A LANGUAGE
// THIS PAGE HAS NOTHING TO DO WITH THE CONTENT THE USER SEES - ONLY THE LANGUAGE THEY SEE IT IN

// IF COOKIES ARE AVAILABLE...
if (isset($_COOKIE['PHPSESSID']))
{
// AND ONE ISN'T SET, SET ONE
if(isset($_COOKIE['Language_Preference']) == FALSE)
{
// SET COOKIE EXPIRY TIME
$number_of_days = 1825; // APPROX. 5 YEARS (ON THE LOGIC THAT PEOPLE CHANGE THEIR PC AROUND EVERY 5 YEARS (MAYBE?))
$date_of_expiry = time() + 60 * 60 * 24 * $number_of_days;

// ENGLISH (UK): UNITED KINGDOM
if($geo == 'GB')
setcookie("Language_Preference", "1", $date_of_expiry, "/", ".example.net");

// SPANISH: SPAIN
elseif($geo == 'ES)
setcookie("Language_Preference", "5", $date_of_expiry, "/", ".example.net");

// ELSE SHOW ENGLISH US
else
setcookie("Language_Preference", "16", $date_of_expiry, "/", ".example.net");

header('Location: http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
}

// SET THE LANGUAGE ID FROM THE COOKIE
$languageid = $_COOKIE['Language_Preference'];
}
// DON'T USE A COOKIE
else
{
// ENGLISH (UK): UNITED KINGDOM
if($geo == 'GB')
$languageid = 1;

// SPANISH: SPAIN
elseif($geo == 'ES')
$languageid = 5;

// ELSE SHOW ENGLISH US
else
$languageid = 16;
}
?>


Any help or insight would be fantastic!

Thanks in advance,
Tom.
10:18 am on Aug 12, 2011 (gmt 0)

Senior Member from ES 

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 11, 2003
posts: 1381
votes: 0


Your missing a close ' in your code above. I doubt that is it but... elseif($geo == 'ES)

According to the logic here they should get Spanish if != cookies and a Spanish IP.

Have you tried echoing into the html source the cookie values for one of these users? For all intents and purposes it seems like they aren't accepting cookies...
10:26 am on Aug 12, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:June 26, 2008
posts:178
votes: 0


Thanks for such a prompt reply!

Sorry, that code error was a result of me trimming it for this forum! Well spotted. ;)

As for the cookies - they are accepting them. That's what is baffling me so much! For example, I visited a competitor who uses a similar arrangement to us and their site remembered my language after a browser close, a restart and an hour later, after a shutdown!

Even my iPhone remembers the language whilst connected to their IP address.

Yet our website does not remember...

I am so confused!
10:42 am on Aug 12, 2011 (gmt 0)

Senior Member from ES 

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 11, 2003
posts: 1381
votes: 0


Okay so the cookies are working, my next guess was that perhaps the clocks hadn't been set on the new machines.

And you have tried to echo the cookies for your site and a PHPSESSID is available?
2:07 pm on Aug 12, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:June 26, 2008
posts:178
votes: 0


Yeah, I've tried the latter. When I get back over to the branch I'll have to see if the clocks work!

That sounds, to me, like a very good suggestion.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members