开发者

Codeigniter Session information

开发者 https://www.devze.com 2023-03-23 06:33 出处:网络
What is the pattern used by CodeIgniter to store session values on the database? I thought it was only a CodeIgniter way to store it but I just found another PHP projet (not using CI) that uses the sa

What is the pattern used by CodeIgniter to store session values on the database? I thought it was only a CodeIgniter way to store it but I just found another PHP projet (not using CI) that uses the same pattern.

a:11:开发者_JS百科
{
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:"desenvolvedor.01@gmail.com";
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";
}


That is what happens when you call serialize on something in PHP.

Serialize documentation:

Generates a storable representation of a value

This is useful for storing or passing PHP values around without losing their type and structure.

To make the serialized string into a PHP value again, use unserialize().

As a note, "storable", here, means "String" (I believe in all cases)

To get a better idea as to what's in there:

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

精彩评论

暂无评论...
验证码 换一张
取 消