【发布时间】:2017-08-04 09:57:54
【问题描述】:
我创建了一个 Codeignier 控制器用于测试,我的控制器使用 codeigniter 会话库:
Test.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Test extends CI_Controller {
function __construct()
{
parent::__construct();
$this->config->load('config');
$this->load->helper("url");
}
function index()
{
$newdata = array(
'username' => 'uname',
'email' => 'uname@some-site.com'
);
$this->session->set_userdata('testsession', $newdata);
redirect("https://mysite/index.php/test/getSession");
}
function getSession()
{
var_dump($this->session->userdata('testsession'));
}
}
会话库在 Codeigniter 的自动加载中加载。
$autoload['libraries'] = array('session');
这段代码在我的使用 Apache + PHP 7.1 和 MySQL 的 Web 服务器上运行良好,但在 Windows 中无法使用 xampp 7.1.1。使用 xampp 时,Codeignitor 会话在 getSession 函数中不起作用。
我的 Codeigniter 配置文件是默认的,我检查了 PHP 的 TimeZone。
【问题讨论】:
-
您可以尝试在 config.php 文件第 317 行更改加密密钥。您必须在 $config['encryption_key'] = 'your key'; 中提及一些字符串。其用户定义
标签: php codeigniter session xampp