0

I'm not familiar with PHP session variables or how they work exactly, but I'm working on a site that has a mobile counterpart. On the mobile site (developed by another company)there's a link to go to the full site that uses a URL ending in '?mobile=false', and I'm just wondering how I can use that to allow mobile users to access the full site?

4
  • Your question is not clear. What do you mean by 'how I can use that to allow mobile users to access the full site?'? What is 'access'? Commented Apr 25, 2012 at 9:53
  • Access as in the ability to view the full site by clicking a link within the mobile site. Commented Apr 25, 2012 at 10:04
  • Are those two different sites? Or is it the same site using a different template? Commented Apr 25, 2012 at 10:04
  • It's two different sites - using the code you suggested has done the trick! Commented Apr 25, 2012 at 10:06

5 Answers 5

1

Put something like this in your entry point:

if (isset($_GET['mobile']) && $_GET['mobile'] == 'false')
{
    session_start(); // If you haven't done so already
    $_SESSION['ShowFullSite'] = true;
}

Then you can check for $_SESSION['ShowFullSite'] afterwards, which will be set as long as the session lives.

Sign up to request clarification or add additional context in comments.

Comments

1

You can access this URI part with $_GET['mobile'] where this will hold false then. And btw. this is not a session variable.

Comments

0

i think you shoould use the Cookies like annother development, not Session. Click Here for the documentation.

Comments

0

you can get the parameter using $_GET['mobile'] in the first page and set the session variable in that page and you use it in other pages. To set the session you need to start the session first. session_start(); Then to set $_SESSION['mobile']=false; You can check in pages by if($_SESSION['mobile']){ } To clear session you can use session_unset();

Comments

0

If I understood, you have two different sites, then if you want to redirect your users, you have to add something like this in the index of your mobile site:

  if (isset($_GET['mobile']) && $_GET['mobile'] == 'false'))
       header('Location: http://www.myfullsite.com/');

1 Comment

Thanks, this is the type of thing I was looking for!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.