dongzhi1851 2012-06-27 22:03
浏览 36
已采纳

Mysql会话数据数组解释

I'm adding session data in my table using Codeigniter's session library.

From documentation:

$newdata = array(
                   'username'  => 'johndoe',
                   'email'     => 'johndoe@some-site.com',
                   'logged_in' => TRUE
               );

$this->session->set_userdata($newdata);

For example in my session table i get this code:

a:7:{s:9:"user_data";s:0:"";s:7:"user_id";s:2:"10";s:8:"username";s:0:"";s:9:"firstname";s:3:"Dan";s:8:"lastname";s:6:"Greeb";s:6:"status";s:1:"1";s:18:"settings_activated";i:1;}

I can't find any documentation on the meaning of all the letters and numbers. What does the syntax mean?

Please notice the last session item settings_activated. I'm using that to check if the user entered his/her settings. It's set to 1 or 0. What does the i mean?

  • 写回答

1条回答 默认 最新

  • douling8772 2012-06-27 22:38
    关注

    To access all session userdata simply type:

    $data = $this->session->all_userdata();
    

    With this you can access

    echo $data['username']; // gives "johndoe"
    

    If you want something specific you can do

    $username = $this->session->userdata('username');
    echo $username;  // gives "johndoe"
    

    As Wrikken mentioned above, the data you see in the actual table is serilized, and CI does not want you interacting with it directly - just use the Session class.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊