I use W3 Total Cache to cache WordPress pages, posts, etc.
Now I made a button that sets the session variable to tell the server if the user wants to see the mobile or desktop and calls this function:
<?php function mobile_css() { if(is_mobile() && !isset($_SESSION['mobile'])) : ?> <link type="text/css" media="all" rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/mobile.css" /> <?php elseif($_SESSION['mobile'] == "ja") : ?> <link type="text/css" media="all" rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/mobile.css" /> <?php endif; }
The problem is that the pages get cached every time they load. So, if I open the page with the mobile session, it will show the mobile phone, if I go to the desktop and pick up this page again, it will still show the mobile version, because it was cached, so the first time it was requested.
Does anyone have an idea on how to prevent this?
source share