我创建了一个处理会话的简单会话类。 但是我遇到了session_id的大问题。
小记:它恰好好几周了。并且突然间它停止工作
情况如何:
http://domain1.com/framework/start/
具有以下会话ID: svplf2tln1j05n75jbokcmhfo3
http://domain1.com/framework/login/
具有以下会话ID: njlqg0jomo00r560bp6k0pje55
这很奇怪。
但了解我的设置很重要:
///######## IF A SESSION COOKIE SHOULD BE SET
if(self::$setsessioncookie === true){
///######## SETTINGS ARRAY
$SessionSettings = array(
'session.cookie_lifetime' => self::$limit, /// **** LIFETIME OF THE SESSION COOKIE (in seconds)
///'session.cookie_path' => self::$path, /// **** THE DOMAIN FOR WHERE THE COOKIE WILL WORK. (single / for all paths on the domain.)
'session.cookie_domain' => self::$domain, /// **** DEFINE THE DOMAIN NAME
'session.cookie_secure' => self::$secure, /// **** ONLY BY SECURE CONNECTIONS
'session.cookie_httponly' => self::$httponly /// **** INDICATE THAT THE SESSION COOKIE IS AVAILABLE THROUGH HTTP PROTOCOLS ONLY (not by Javascript)
);
///########==================================================
///######## SET THE SESSION COOKIE PARAMETERS
///########==================================================
///######## RUN THROUGH ALL SETTINGS
foreach($SessionSettings as $Option => $Setting){
///######## IF THE OPTION IS NOT EMPTY
if($Setting !== NULL){
///######## SET THE SETTING
ini_set($Option, $Setting);
}
}
如你所见,我评论说:
'session.cookie_path' => self::$path
因此,它不应仅限于一条路径。 但问题仍然存在。
在此之前,我设置了一个会话cookie:
///########==================================================
///######## STORING THE SESSION ID IN A COOKIE
///########==================================================
setcookie(
self::$SessionName, /// **** SET THE COOKIE NAME
session_id(), /// **** SET THE COOKIE CONTENTS
(time() + self::$limit) /// **** MAX DURATION OF THE COOKIE LIFETIME
);
///########==================================================
或者我应该在设置 ini_set ??
之前执行此操作小更新: 我安装了FireFox webdeveloper扩展,当我点击:“删除路径cookie”时,系统会退出并允许我正确登录。
这可能表示路径已设置?但我已经评论了这个???
也许我应该设置路径但是指定深度?
例如ini_set('session.cookie_path', 'http://domain1.com/*')
?