dcp3450
dcp3450

Reputation: 11187

How do I allow mobile users to bypass the redirect?

When a mobile user views my site they are redirected to a mobile version. I have a "view full" option to allow them to view the actual site instead. Problem is when they do they will get redirected back. Is there away to bypass the redirect or only redirect the first time?

Upvotes: 3

Views: 3460

Answers (5)

dcp3450
dcp3450

Reputation: 11187

I did it using sessions. I check HTTP_REFERER to see if our mobile address is in the address using strpos. If it is then I set a session value. As long as the session is still active they can use the full site. If they return to the mobile site the the session is destroyed. Works perfect!

Upvotes: 1

borayeris
borayeris

Reputation: 2650

What I suggest you is using the database. When somebody enters your site write the IP of every user and also version of the site.

|____ id ______| site version |

| 88.75.125.xxx | normal |

| 93.108.111.xxx | mobile |

When the user changes the version you can edit the proper id.

Upvotes: 0

Steven
Steven

Reputation: 18014

As far as I know, almost all mobile browsers have basic cookie support. PHP setcookie (documentation here) will allow you to do something like this:

setcookie('default_view', MOBILE);

Where MOBILE is defined ahead of time. You're also free to use a string here.

The upside is you won't have to worry about the query string once this cookie is set. SLaks' solution will work, but you would have to pay attention to append redirect=false to every URL that has a redirect-checker.

Upvotes: 5

Boldewyn
Boldewyn

Reputation: 82734

Adding to SLaks' answer, you could add a cookie 'redirect=false'. The advantage of this is, that you don't have to place the GET parameter on every link, so people stay on the normal page even after following internal links.

Upvotes: 1

SLaks
SLaks

Reputation: 887453

You can add a querysting such as ?redirect=false.
Before redirecting, check for this querystring.

Upvotes: 2

Related Questions