[英]How to access codeigniter session from external files
我想从外部文件访问codeigniter会话,因此当我尝试从外部打印会话变量时,没有空数组
Codeigniter sessions are stored in a database table called ci_sessions
unless you renamed it. 除非您重命名,否则ci_sessions
会话将存储在名为ci_sessions
的数据库表中。 Thus they are not accisible in the $_SESSION
variable of PHP 因此,它们在PHP的$_SESSION
变量中不可用
heres what you do 这是你的工作
ci_session
unless you changed the value of sess_cookie_name
in the config.php
file 除非您在config.php
文件中更改了sess_cookie_name
的值,否则包含会话ID的cookie将称为ci_session
ci_sessions
table mentioned earlier and confirm that the clients ip_address
and user_agent
matches those in the row you just retrieved (this is for security reasons) 从数据库中获取前面提到的ci_sessions
表中的行,并确认客户端ip_address
和user_agent
与您刚获取的行中的客户user_agent
匹配(这是出于安全原因) user_data
column. 实际的会话数据将保存在user_data
列中。 You will have to parse this and obtain the key/value pairs. 您将必须对此进行解析并获取键/值对。 I suggest finding the relevant function for this in the sessions.php file in codeigniters system folder. 我建议在codeigniters系统文件夹的sessions.php文件中找到与此相关的功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.