我遇到了一个有趣的小问题,我不知道该怎么做。我正在运行此代码:
index.php :(包装在ob_start()中以缓冲所有内容,以便在输出任何内容之前设置标头)
$session = new Sessions();
$session->create('user');
$session->create('system');
$session->create('data');
会话课程的一部分:
public function create($session){
$cookie_name = $this->get_cookie_name($session);
if (!isset($_COOKIE[$cookie_name])) {
if (session_status() != PHP_SESSION_NONE) {
session_write_close();
session_unset();
}
session_set_cookie_params(0, '/', COOKIE_URL);
session_save_path(TEMP . 'sessions');
session_name($cookie_name);
session_start();
session_regenerate_id();
$session_id = session_id();
$_SESSION['PHP_SESSION_NAME'] = $session;
session_write_close();
session_unset();
echo '$cookie_name: ' . $cookie_name . '<br>';
echo 'SESSION_ID: ' . $session_id . '<br>';
}
}
从php发送的标头:
Set-Cookie:ses_user=7o5uoqdn95a3kt7k6argb2rab7dar9oe94v96rqqdpqk47g7m00g80m2j3fbcs50r1b2b02q4tsn7p98jq9cf6lq1uq1bv717s74p02; path=/; domain=.certastic.com; HttpOnly
Set-Cookie:ses_system=ac2f362l3fmui0uon31hu1h64k4sa0mlj9g3kq3c7bd7tsnpgbon7fehqqfiqf5sj50jajqqd4km7l2hal6vfd6okg7lfohg1tt66g2; path=/; domain=.certastic.com; HttpOnly
Set-Cookie:ses_system=u84aiiun9ji8t8m0akkv0dpdmu27gcan4rik0klkg163j43ii849elde3alubj6bsljai8vtkptt18oplgo3s9421hk50dr3c4s27t1; path=/; domain=.certastic.com; HttpOnly
Set-Cookie:ses_data=u84aiiun9ji8t8m0akkv0dpdmu27gcan4rik0klkg163j43ii849elde3alubj6bsljai8vtkptt18oplgo3s9421hk50dr3c4s27t1; path=/; domain=.certastic.com; HttpOnly
Set-Cookie:ses_data=vn7k19iu91sq9mf3tnrrurqddhluk3pqsi5p8rs10unhnk8rus9702uuoml663l5nnhmj084l6t6cve78ru5th2jqk3mub8f6tei6h1; path=/; domain=.certastic.com; HttpOnly
Set-Cookie:ses_user=ac2f362l3fmui0uon31hu1h64k4sa0mlj9g3kq3c7bd7tsnpgbon7fehqqfiqf5sj50jajqqd4km7l2hal6vfd6okg7lfohg1tt66g2; path=/; domain=.certastic.com; HttpOnly
起初它起作用了,我一直在删除cookie来测试一些东西。一段时间后它停止工作, cookie将不会设置,如果我更改会话的名称将起作用。它在Firefox中也可以正常工作。任何人都知道我能做些什么才能让它发挥作用?