Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8138041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:22:17+00:00 2026-06-06T11:22:17+00:00

I am setting up a simple mobile/desktop redirect using the technique from this page

  • 0

I am setting up a simple mobile/desktop redirect using the technique from this page. I am also setting a cookie on the mobile site so that if the user wants to link back to the desktop site, that cookie will be read and the redirect will not take place. I am dealing with WordPress sites and while the redirect does work, the cookie is not working properly. Here is what is happening:

  • Mobile redirect does work
  • Cookie is successfully set (confirmed with a test page outside WP)
  • When the user clicks back to the desktop site, the cookie isn’t not being seen and the user gets dumped back to the mobile site again.

I tested my code using 2 external static pages, and everything works 100%. Just not when I use the same exact code in WordPress. Here is my code from the header.php files on each site:

Desktop site

<?php
    include('Mobile_Detect.php');
    $detect = new Mobile_Detect();
    if ( $detect->isMobile() && isset($_COOKIE["mobile"]) ) {
         $detect = "false";
    }
    else if ( $detect->isMobile() ) {
         header("Location:http://m.example.com");
    }
?>

Mobile site

<?php setcookie('mobile','m', time()+3600, '/','.example.com'); ?>

The PHP code is the first thing in the file, before any HTML and there is no errant whitespace before or after it. I’ve tested this code by echoing some text and the script is there and doing what it should. It’s just that one problem of the cookie not being seen and stopping the redirect to the mobile site like it should.

After many hours, I need some help please!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:22:18+00:00Added an answer on June 6, 2026 at 11:22 am

    Problem solved!

    The desktop site, running Drupal, was the problem. It’s a caching issue or something, because if I run cron, the whole detection scheme works perfectly. The second time around, it doesn’t. It only works one time right after running cron. I’m going to have to get our resident Drupal pro to figure it out.

    Thanks for all the help, though!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am setting up a simple test page in Python. I only have two
I'm setting up some simple url rewriting rules using mod_rewrite and a .htacces file,
How to implement scrolling animation? I'm ok with setting a simple AlphaAnimation that triggers
I am trying to create a simple setting in Orchard that appears in the
I am setting up a simple billing system, where I have a table that
I am setting up a simple CRUD page for my website content and would
I am trying to deploy a simple windows desktop app using a SQL Server
I have made a simple application for my iphone using jQuery Mobile and Phonegap.
I have simple issue setting a two-way databinding of a checkbox in Silverlight 3.0.
I am just setting up a simple library application, basically a collection of Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.