在Code Igniter中启动会话

时间:2012-03-10 22:58:24

标签: php codeigniter session syntax-error

从视图顶部开始:

<?php ### CREATE SESSION **
$this->load->library('session'); $this->load->library('encrypt');

$newdata = array(
'session_id'  => random hash,
'ip_address'    => 'string - user IP address',
'user_agent'    => 'string - user agent data',
'last_activity' => timestamp
);

$session_id = $this->session->userdata('session_id');

?>

获取此错误:

Parse error: syntax error, unexpected T_STRING, expecting ')'  on line 5

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

查看您的新评论,要开始一个会话,您需要做的就是:

<?php
   //Start session
   $this->load->library('session');

   //Try retriving data:
   $session_id = $this->session->userdata('session_id');
   echo $session_id;