可以说我有一个名为PHP会话空使用SSL?
https://url.com/test 和https://url.com/test2
class Test extends Application {
# put global things here
function __construct() {
$this->library ('sessions');
$this->helper ('active');
}
function test() {
$this->sessions->set('login',1);
echo session_id().'<br/>';
echo $this->sessions->get('login');
}
function test2(){
if (is_get('d')) {
$this->sessions->del('login');
}
echo session_id().'<br/>';
echo $this->sessions->get('login');
}
}
页当我使用http://url.com/test和http://url.com/test2
它给我像
第1页的东西
326o42a9pblv48c9kb5va1mgorsf35gr39gu0tg8a6umr0rcdrgmasmmtbqvqm0dqa086bn3od07mpc11b65so62c1atrr3cgemaha1
1
第2页
326o42a9pblv48c9kb5va1mgorsf35gr39gu0tg8a6umr0rcdrgmasmmtbqvqm0dqa086bn3od07mpc11b65so62c1atrr3cgemaha1
1
但是当HTTPS
第1页
326o42a9pblv48c9kb5va1mgorsf35gr39gu0tg8a6umr0rcdrgmasmmtbqvqm0dqa086bn3od07mpc11b65so62c1atrr3cgemaha1
1
第2页
326o42a9pblv48c9kb5va1mgorsf35gr39gu0tg8a6umr0rcdrgmasmmtbqvqm0dqa086bn3od07mpc11b65so62c1atrr3cgemaha1
1不见了。 问题是我想分享从页面测试到页面测试2的会话。
编辑* 这里是我的会话类
class Sessions {
private $config;
public function set($key, $value) {
if (isset ($_SESSION [$key])) {
return false;
}
if (! isset ($_SESSION [$key])) {
$_SESSION [$key] = $value;
return true;
}
}
public function get($key) {
if (! isset ($_SESSION [$key])) {
return false;
}
if (isset ($_SESSION [$key])) {
return $_SESSION [$key];
}
}
public function del($key) {
if (! isset ($_SESSION [$key])) {
return false;
}
if (isset ($_SESSION [$key])) {
unset ($_SESSION [$key]);
return true;
}
}
public function flush() {
// do we still need this?
$_SESSION = array();
session_destroy();
$this->refresh();
}
public function refresh() {
session_regenerate_id (true);
}
function __construct() {
$this->config = config ('sessions');
# doing some importing things
ini_set ('session.cookie_httponly', $this->config ['cookie_httponly']);
ini_set ('session.gc_probability', $this->config ['gc_probability']);
ini_set ('session.gc_divisor', $this->config ['gc_divisor']);
ini_set ('session.hash_function', $this->config ['hash_function']);
ini_set ('session.gc_maxlifetime', $this->config ['gc_maxlifetime']);
# start the engine
session_start();
}
}
的配置
$config['sessions'] = array(
'gc_probability' => '0',
'gc_divisor' => '100',
# 'cookie_domain' => 'www.networks.co.id',
# http://us2.php.net/manual/en/session.configuration.php
'cookie_httponly' => FALSE,
# SHA512
'hash_function' => 'SHA512',
'gc_maxlifetime' => '1800'
);
感谢您寻找在
亚当·拉马丹
你使用某种你想提到的框架吗? – Jakub 2011-03-26 14:09:07
不使用自定义框架,这是奇怪的? – 2011-03-26 14:20:10