Cookie适用于这种情况.只需记录位置ID,然后下次重定向到该位置!
// store an array of location cookie names and there location values
$places = array('us'=>'/united-states.php');
// After user chooses a location, store the cookie based on his choice: in this case, us!
setcookie('location','us', time() + (3600 * 24 * 7));
// On a new page check the cookie is set, if it is then redirect users to the value of that cookie name in the array!
if(isset($_COOKIE['location'])){
header('Location: '.$places[$_COOKIE['location']]);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
259 次 |
| 最近记录: |