Page 1 of 1

PHP session variable for list href choice

Posted: Sat May 07, 2016 8:52 pm
by cjkeane
Hi I need to figure out a way to retain a visitors choice of region when they first visit my site.
This is what I have so far:

Code: Select all

session_start();
if(isset($_GET['region'])){$_SESSION['region'] = $_GET['region'];}

<li><a href="#" id="region">North America </a></li>
<li><a href="#" id="region">Asia</a></li>
                      
how do I make sure that if North America is chosen then that that link is highlighted and vice versa.

Re: PHP session variable for list href choice

Posted: Sat May 07, 2016 9:01 pm
by requinix
1. Figure out what HTML markup you need to make the link appear "highlighted".
2. Look at the value in $_SESSION to see what the current region is.
3. For each link, if the region matches the session value then show it highlighted, otherwise show it normally.