我尝试在我的网站上使用会话。 只有我的镀铬不起作用。当我打开我的网站时,我总是使用新的PHPSESSID获得新的SET-Cookie。 (这不是SSL网站,我没有使用隐身模式)
PHP代码:
session_start();
$_SESSION['name'] = 'xyz';
响应标题:
Cache-Control:no-store, no-cache, must-revalidate
Connection:keep-alive
Content-Type:text/html; charset=UTF-8
Date:Mon, 19 Feb 2018 15:21:03 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Pragma:no-cache
Server:nginx/1.10.3 (Ubuntu)
Set-Cookie:PHPSESSID=t3t7efdk9ljpt1vrn62rmv2647; path=/
Transfer-Encoding:chunked
请求标题:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:pl-PL,pl;q=0.9,en-US;q=0.8,en;q=0.7
Cache-Control:max-age=0
Connection:keep-alive
Cookie: phpMyAdmin=of4b155ds75s045438t7ck352cgmfoae
DNT:1
Host: example.com
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36
重装页面后 - 在请求标题中 - 没有' PHPSESSID'曲奇饼。其他cookie工作正常。
我在Microsoft Edge上测试同一个站点 - 一切正常。
答案 0 :(得分:1)
设置Exam
不会设置将在Cookie中使用的会话名称。
您的会话名称为export class Exam {
constructor(
public Id: number,
public Title: string,
public Questions:Question[]){
}
}
。这是在PHP session.name设置的session_start期间设置的。这将是您的cookie中使用的内容。
显示$_SESSION['name']
的请求标头不会恢复您启动的会话。它们应该按照响应头。
PHPSESSID