php help
- Started
- Last post
- 8 Responses
- dbloc
I have a mobile site located at
www.example/m/if a user goes to www.example.com it forwards them to www.example/m/
I want to give the option to view the full site from the mobile.
I need to detect if the user is coming from the /m/ directory, and not run the redirect script if so.
Do I need to set a cookie for this?
- sureshot0
www.example.com doesnt work. I'm using FF btw.
- chrisRG0
a session var would do the job!
- noel0
cookie or session wold be effective
- dbloc0
not familiar with a session var. is that similar to a cookie?
- mikotondria30
have
session_start();
at the top of the pages, then it's just like setting/reading a POST or GET, so like
$_SESSION[var] = 'foo';
and on the other page,
if (isset($_SESSION[var] && $_SESSION[var]=='foo)){ etc...It's all on the php site, and other places, of course :)
- session_start has to be BEFORE any html or code or even "space" is written to the browser...vaxorcist
- mantrakid0
Sessions are like cookies but theyre stored on the server.
http://www.tuxradar.com/practica…
//Start using sessions - put this at the top of your code
session_start();//Then set a session variable
$_SESSION['use_mobile'] = 'y';//Now you can change that variable based on some logic...
if ($_SERVER['HTTP_REFERER'] == 'http://www.example.com/m') {
$_SESSION['use_mobile'] = 'n';
}etc...
- ETM0
This redirection script has a built in ability to understand a callback and not redirect the user back to mobile:
https://github.com/sebarmeli/JS-…
- dbloc0
Thanks all. Setting a cookie worked great.