我正在使用 PHP 将包含 @#$(描述一些)等特殊字符的变量存储到会话和 cookie 中,但是当我检索它们时,我无法在存储的会话和 cookie 变量中看到特殊字符。提前致谢.
//storing
$_SESSION['userid'] = $db_id;
$_SESSION['email'] = $db_email;
$_SESSION['password'] = $db_pass_str;
setcookie("id", $db_id, strtotime( '+30 days' ), "/", "", "", TRUE);
setcookie("email", $db_email, strtotime( '+30 days' ), "/", "", "", TRUE);
setcookie("pass", $db_pass_str, strtotime( '+30 days' ), "/", "", "", TRUE);
//Retreivel
if(isset($_SESSION["userid"]) && isset($_SESSION["email"]) && isset($_SESSION["password"]))
{
$log_id = preg_replace('#[^0-9]#', '', $_SESSION['userid']);
$log_email = preg_replace('#[^a-z0-9]#i', '', $_SESSION['email']);
$log_password = preg_replace('#[^a-z0-9]#i', '', $_SESSION['password']);
// Verify the user`enter code here`
}
else if(isset($_COOKIE["id"]) && isset($_COOKIE["email"]) && isset($_COOKIE["pass"]))
{
$_SESSION['userid'] = $_COOKIE['id'];
$_SESSION['email'] = $_COOKIE['email'];
$_SESSION['password'] = $_COOKIE['pass'];
}
当我回显会话变量时,我看不到我存储的特殊字符。例如:我存储了 test@example.com,但是当我查看时,我只能看到 testexample.com。