2011-07-26 124 views
0

CodeIgniter用于将会话值存储在数据库上的模式是什么? 我认为这只是一个CodeIgniter的方式来存储它,但我只是发现另一个使用相同模式的PHP projet(不使用CI)。Codeigniter会话信息

a:11: 
{ 
s:10:"usuario_id"; 
s:1:"1"; 
s:13:"usuario_login"; 
s:5:"admin"; 
s:13:"usuario_senha"; 
s:40:"8cb2237d0679ca88db6464eac60da96345513964"; 
s:12:"usuario_nome"; 
s:13:"Administrador"; 
s:13:"usuario_email"; 
s:26:"[email protected]"; 
s:18:"usuario_registrado"; 
s:19:"2011-05-06 16:25:33"; 
s:13:"usuario_chave"; 
s:0:""; 
s:14:"usuario_status"; 
s:1:"1"; 
s:14:"usuario_logado"; 

b:1; 
s:8:"setor_id"; 
s:6:"images"; 
s:12:"setor_numero"; 
s:3:"017"; 
} 

回答

4

这就是当您在PHP中调用serialize时发生的情况。

序列化文档:

生成一个值

这是用于存储或传递PHP值,而不会失去它们的类型和结构是有用的可存储表示。

要使序列化的字符串再次成为PHP值,请使用unserialize()。

作为一个说明,“可存储”,在这里,意思是“字符串”(我相信在所有情况下)

为了得到一个更好的主意,什么是在那里:

a:11: // <-- array has 11 keys (this will alternate key/value 
{ 
s:10:"usuario_id"; // <-- string 10 characters long which is the first key 
s:1:"1"; // <-- string 1 character long which represents the first value 
s:13:"usuario_login"; // <-- string 13 characters long (second key) 
s:5:"admin";// <-- string 5 characters long (second value) 
// yada yada 
s:14:"usuario_logado"; 
b:1; // <-- boolean TRUE 
// yada yada 
} 
+0

正确,和b将布尔?但没有名字或价值?奇数 – Cystack

+0

@Cystack在数组中,它将是:array('usuario_logado'=> True);' – cwallenpoole