我使用PHP將包含特殊字符(如@#$)的變量存儲到會話和cookie中,但是當我檢索它們時,我無法看到特殊存儲的會話中的字符和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'];
}
當我回顯會話變量時,看不到我存儲的特殊字符。 例如:我保存了[email protected],但當我查看時,我只能看到testexample.com。
你需要更多地解釋 –
哪裏出現此問題顯示你的代碼。告訴我們這個代碼運行時的樣本輸入/輸出值。 –
嗨外星人和邁克,我已經添加了code.Thanks您的支持提前。 – ravikanth