PHP session variable for list href choice

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cjkeane
Forum Contributor
Posts: 217
Joined: Fri Jun 11, 2010 1:17 pm

PHP session variable for list href choice

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP session variable for list href choice

Post 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.
Post Reply