Dom
Dom

Reputation: 878

Javascript mobile site redirect issues

I'm using code to redirect mobile devices that are under 699 pixels wide to go to our mobile site. This method utilizes JavaScript and cookies and follows some basic logic:

On the mobile site I simply have a link like the following that someone can click to set the cookie

http://www.example.com?skipmobile=1

This code works properly for me and most people, but we are having customers saying When they click the full site link it sends them right back to the mobile site. According to the code this means they do have cookies enabled but their cookie isn't getting set.

Is there something I need to do to this code that's missing?

UPDATE: So this problem is a bit of an oddball. One of our employees is having the issue as well so we at least have a phone to test on. We have a live site and a dev site. It works for him of we go to the dev site and redirect but it doesn't for the live...

Does this help anyone come up with conclusions? The code is the same on both sites.

Upvotes: 0

Views: 66

Answers (1)

Annonymous
Annonymous

Reputation: 978

You should try deleting all cookies related to your site beforehand, as this should clear up any problems. This is a link to a great function that should do this for you:

Clearing all cookies with JavaScript

You could also put that you don't want it to cache for a while in the headers (using the cache control var) to make sure that if the phone is storing any problems these are removed

Upvotes: 1

Related Questions