index.php
//接收到参数后,设置cookies
//var_dump($_GET['user_id']);die;
if(!empty($_GET['user_id'])){
setcookie('image_user_id',$_GET['user_id'],time()+3600,'/','www.qcy.com');
}
//var_dump($_COOKIE);die;
//收到参数以后解密,并转化数组
if($_COOKIE['image_user_id']){
//user_id=1&username=admin
echo 'not empty';
$user = base64_decode($_COOKIE['image_user_id']);
var_dump($user);
$user_arr = explode('&', $user);
$map_user = array();
var_dump($user_arr);
foreach ($user_arr as $key => $value) {
$tmp = explode('=', $value);
echo '*****';
var_dump($tmp);
echo '*****';
$map_user[$tmp[0]] = $tmp[1];
}
var_dump($map_user);
}
?>
show.php
var_dump($_COOKIE);
echo "
";
if($_COOKIE['image_user_id']){
echo 'login';
echo '
';
echo $_COOKIE['image_user_id'];
}else{
echo 'logout';
}
?>