1

I just wrote a little plugin that detects if the user is on a mobile browser and if so detects them away from the WordPress site to a mobile (simple) version of part of the site.

As I got to thinking I'm redirecting user who may want to see the full site. I can easily add a check by creating a URL such as http://example.org?force_web=true The only problem is my plugin checks the top of each page to see if it's mobile so I would need to set force_web=true on all pages.

The other idea would be to use sessions but it seems WordPress doesn't support sessions unless you add session_start(); to your wp_config.php file which I don't want to ask the plugin users to do.

Is this something others have experienced? Is the best way to re-write all permalinks with the addition of my variable?

Open to ideas and suggestions

  • 2
    why would you need to redirect the user? simply check if he's using a mobile browser and display different content if he is. – onetrickpony Jan 9 '11 at 11:47
  • That's exactly what I'm doing. I wanted to extent this functionality to give a link to the full site from the mobile site. The problem is if they were on a mobile device it would just redirect from the main site to the mobile site. – Brooke. Jan 10 '11 at 4:47
1

As Ambitious Amoeba said, just do the check on each page load; it shouldn't be that expensive.

Otherwise, another possibility to store a single bit of information would be to use browser cookies.

|improve this answer|||||
  • Oh Cookies I didn't think of that! Good call.I'll look into that option. – Brooke. Jan 10 '11 at 4:45
  • yes it's months later, but i got around to implementing this and ended up just setting a cookie. – Brooke. Apr 6 '11 at 5:14
  • wow. nice to see you on here BR... – TJ Sherrill Jan 13 '12 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.