Would it be possible to take the fundamental functions of this post
>> http://www.sitepoint.com/forums/showthread.php?t=652444
and add the ‘remember me’ function?
Basically, I want to allow my site visitors to select and set their location and when they return to my index page, the site will remember their selection and redirect them to a sub directory.
Thank You!
I don’t know what you’re asking. If the users can select multiple states, that doesn’t really fit with a redirection, and you can only redirect to one location.
Also, there is a mistake in my previous post, but I can’t edit it.
The second line of code should be this:
setcookie('state', $state, time()+3600*24*365);
I had a quote after $state which would cause a syntax error.
Thanks, Cranial-Bore. What I have to set that same ‘thread’ for each selection (or State) in this case?
I just skimmed the other post, but if you determine some value that you use for the basis of the redirection, just put it in a cookie, and check for that cookie on the index page.
//Where the user currently selects their location
$state = 'KS';
setcookie('state', $state', time()+3600*24*365);
//Index page, check for cookie
if(isset($_COOKIE['state'])) {
$state = $_COOKIE['state']; //KS
//lookup redirect location based on $state
}
[fphp]setcookie[/fphp]