0

i found a script to link to an subdomain if you are on a mobile site. but how can i manage to have a button on my mobile site to link to the full view-non-subdomain in php?

heres the code:

if(strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') ||
   strstr($_SERVER['HTTP_USER_AGENT'], 'Android')) {
   header('Location: http://m.ihreseite.ch');
   exit();
}

thanks

Max
  • 608
  • 1
  • 7
  • 23

2 Answers2

2

This can give you an idea. You can set it basicly to session and get this session variable. Check each page if visitor choose mobile or real website. Then redirect them to website which they want to surf.

ActuallyMAB
  • 224
  • 1
  • 10
  • You must check in head a session varible like $_SESSION['preferred_website'] is mobile or real. You can learn to use about sessions here: http://php.net/manual/en/features.sessions.php – ActuallyMAB Jun 29 '12 at 06:57
0

You can set a variable to flag that you want to stay on the full site, then save this in a session or cookie. You can see an example in a previous questions (or this one) along the same lines.

Community
  • 1
  • 1
John C
  • 8,223
  • 2
  • 36
  • 47
  • auto direct if i am on a smartphone (works already) but when i click a link on the mobile site called "switch to full version" i should be redirected to the full website (site.de not mobile.site.de) and not be back-redericted to the mobile site – Max Jun 29 '12 at 06:53