When the mobile user goes to view the full page (link is "http://[my site].com?mobile=false"), the URL changes briefly, but immediately reverts to m.URL - so it's not possible to view the full site from mobile with automatic redirection turned on.

I've tried setting the cookie to 0 - no difference. Everything else seems to work well and I don't think anything is set improperly - I do have an alternate front page for mobile (which works nicely) - any ideas? Thanks much for this terrific module - almost there, at least in my case!

#9 1092144_cookie_has_no_effect.patch2.65 KByang_yi_cn
Members fund testing for the Drupal project. Drupal Association Learn more


petersax’s picture

Ok, first time poster on d.o, fresh from drupalcon chi. I'm pretty sure this is going to violate some protocol since I'm actually on 6.x-2.1, but I'm having the same issue and I think I can help, so here goes. If anyone wants to chime in and let me know where this should have gone, please do.

I couldn't find any reference in the module code to a 'mobile' querystring variable. I did find a 'nomobile' in $_GET, with comment "// backwards compatibility with the nomobile parameter," so apparently this is old, but it does work. My [site].com redirects mobile users to m.[site].com. Mobile users going to [site].com/?nomobile=true successfully sets the cookie to redirect to desktop. [site].com/?nomobile=false unsets it, and sends back to m.[site].com.

Important note: sending mobile users who desire deskop to m.[site].com/?nomobile=true (notice the m.) does not work, since it sets a cookie on that domain, then redirects to [site].com where there is no cookie, so it redirects to m.[site].com which redirects back, so we have a redirect loop, which is nobody's idea of a good friggin time.

I tried setting the cookie domain (which my colleague pointed out sounds like cookie dough mane; who wouldn't want one) in settings.php to [site].com so that the cookies are the same and the redirect loop doesn't happen, but I haven't been able to get it to work and I figured my time would be better spent posting long-winded half-solutions on d.o. Bye.

bcobin’s picture

Status: Active » Closed (fixed)

Well, saxdev, I'm not sure if it's exactly what you intended, but your post helped a lot. I had appended the query directly, without the '/'. With the proper string - it seems to work fine!

I will set this to "fixed" thank you one and all!

bcobin’s picture

Status: Closed (fixed) » Needs review

OK - I spoke too soon - yes, you do need the slash, but saxdev, you are right on the money: your solution does work, while the instructions in the current documented do not - at least over here, anyway.

So, for dummies like me, if you're out there, here's what works:

With automatic redirection on (using domain redirection with "m." prefix), send users to the non-mobile site by setting the link to http://[site]/?nomobile=true

To return to mobile site, send users to http://m.[site]/?nomobile=false

Looks like that's working for me. Setting this to "needs review". Thanks a ton for this, saxdev and, of course to twom for a great module! You're all rockstars...

twom’s picture

Hi all,

Thx for the feedback on the module. Currently there is some confusion with the nomobile=true functionality.

Some time ago, I decided to replace that functionality by a more transparent way of controlling the output.
You can now use

  • ?device=desktop => force the the device to be recognized as desktop
  • ?device=mobile => force the the device to be recognized as desktop
  • ?device=[device_group] => force the the device to be recognized as the specified device group
  • ?device=auto => reset everything and enable the normal behavior

This method allows much more flexibility and removes the double negation ?nomobile=false

http://drupal.org/node/459686 - see Force the user to see a specific version of the site (I updated the documentation)

I also removed all references to the ?nomobile method... It is hard to keep backwards compatibility :)

Let me know if you see any other issues, or improvements I can make in the documentation.

bcobin’s picture

Seems to work nicely! Two small notes:

1. Old code (?mobile=) won't work and will need to be changed - no biggie.

2. I think you have a typo in the second list item; "?device=mobile => force the the device to be recognized as desktop" should be "?device=mobile => force the the device to be recognized as mobile" right?

Thanks, twom - rockin' module!

twom’s picture

Status: Needs review » Fixed

yes, that was a type:

?device=mobile forces the device to be recognized as mobile!

Glad it all works for you!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

yang_yi_cn’s picture

Status: Closed (fixed) » Active

tried the latest dev and still doesn't work.

?device=desktop (try to force desktop version while using a mobile device) works for the first time, but then any link goes to redirection loop

?device=mobile (try to force mobile version when using a desktop) have no effect at all

yang_yi_cn’s picture

Title: Appending ?mobile=false to URL seems to have no effect » Appending ?device=desktop to URL seems to have no effect
Status: Active » Needs review
2.65 KB

My problem seems to be caused by the "REQUEST_TIME", this is not defined on my server, so the cookie always expires and never get set.

It looks like this constant is introduced in Drupal 7 but not available in Drupal 6.

I changed it to use "$_SERVER['REQUEST_TIME']", as attached.

venusrising’s picture

Does this setting get done in the admin url area? Not sure where to place it.

Pol’s picture


I'm encountering some problems with dev version:

On a desktop:
When I browse my site using ?device=mobile, I see the mobile version as it should.
If I use ?device=desktop, I see the desktop version.
If I use ?device=auto, I see the desktop version.
If I use no argument, I always see the mobile version, even on a desktop computer.

I think there is a problem with the cookie setting, I don't have time to dig up the code right now, but the dev version is clearly not usable. (I took it because I had this bug #1105750: Call to undefined function url())

@yang_yi_cn: I think your patch is now useless, they are using time() in place of $_SERVER['REQUEST_TIME'] in the dev version.

cdracars’s picture

This issue seems to still be relevant.

minorOffense’s picture

Status: Needs review » Needs work
venusrising’s picture

We are using the stable version but when clicking on the view full site it goes to the full site unless user clicks a link at which time it takes them back to the mobile site.

mibfire’s picture

If "Switch theme based on the URL" is checked then this isnt working.

Devin Carlson’s picture

Priority: Normal » Major
minorOffense’s picture

Assigned: Unassigned » minorOffense
Cardinals27’s picture

Title: Appending ?device=desktop to URL seems to have no effect » Appending ?device=desktop multiple google indexes

our redirections are working perfectly with the ?device= variable. we have links in the footer on our desktop and mobile themes that will allow the user to force-switch the theme ... however ... google has taken it upon themselves to index 3 versions of the same page:

for instance:

are all 3 indexed as separate pages. is there a way to hide the appended variable or some way to prohibit indexing the variabled url?

amarslaksh’s picture

Hi All,

For Drupal 7 I created a custom block and its working fine.. (place the block as per the requirement where u need )...

function mobile_tools_block_view($delta) {
$block = array();
if($delta == "mobile_tools"){
$block['content'] = mobile_tools_block_message();
return $block;

* Helper function returning the configurable message for the notification
function mobile_tools_block_message() {

$site = _mobile_tools_site_detection();

if ($site == 'mobile' ) {
$output = variable_get('mobile_tools_desktop_url', '');
$output = l(t('View Full Site'),'http://'. $output, array('#theme' => 'theme_default'));
echo $output;
else if ($site == 'desktop' ) {
$output = variable_get('mobile_tools_mobile_url', '');
$output = l(t('View Mobile Site'),'http://'. $output, array('#theme' => 'theme'));
echo $output;