下拉菜单设置会话变量

I'm using a wordpress theme that I built and I'm trying to get a dropdown box to set a session variable so I can use it to load a specific container according to the value of the variable

this is a snippet from the header.php document where everything is pretty much completed through.

Every page will contain this data

The problem isn't the session variable being set but it seems it is cleared once I goto another page.

Please could someone assist me.

Thanks,

<?php
$_SESSION['city_selected'] = $_POST['city_select'];
?>
                        <div class="cities">Select City <form method="post" action="<?php echo $PHP_SELF;?>"><select name="city_select" id="city_select" onchange="submit();"><option>-----</option>
                        <option value="Beijing">Beijing</option>
                        <option value="Shanghai">Shanghai</option>
                        <option value="Guangzhou">Guangzhou</option>
                        <option value="Manila">Manila</option>
                        <option value="HongKong">Hong Kong</option>
                        <option value="Tokyo">Tokyo</option>
                        <option value="Seoul">Seoul</option>
                        <option value="Taipai">Taipai</option>
                        </select></form></div>

** EDIT **

<?php if(isset($_POST['city_select'])) { $_SESSION['city_selected'] = $_POST['city_select']; } ?> 

worked for me :) cheers

Make sure you have called session_start() before attempting to set any session variables. You must also call session_start() on any page where you wish to access session variables.

<?php
session_start();
$_SESSION['city_selected'] = $_POST['city_select'];
?>
<?php if(isset($_POST['city_select'])) { $_SESSION['city_selected'] = 
$_POST['city_select']; } ?>

This worked for me.