Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 967
dcp3450 Avatar asked Dec 05 '25 08:12

dcp3450


2 Answers

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.

like image 196
Steven Avatar answered Dec 07 '25 20:12

Steven


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

like image 27
SLaks Avatar answered Dec 07 '25 22:12

SLaks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!