-4

starting at the top of the view:

<?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');

?>

Getting this error:

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

how do I fix this?

8
  • 1
    Is this your real code? Did you forget that variables start with $?
    – Mog
    Mar 10, 2012 at 23:00
  • 1
    It's not updated. By the way, this stuff doesn't belong in a view file.
    – Mog
    Mar 10, 2012 at 23:01
  • 3
    This has nothing to do with sessions, or code igniter. Its just a syntax error, and you news to learn to recognize simple things like that before posting for help. Mar 10, 2012 at 23:02
  • Should this part 'string - user IP address' be a php call to get the REMOTE_ADDR ? Sorry, was following: codeigniter.com/user_guide/libraries/sessions.html , its what they did
    – CodeTalk
    Mar 10, 2012 at 23:02
  • What are you trying to accomplish with this anyways? The citation in the user guide is nothing more than an explanation of what data CI uses internally when it saves a session to the database.
    – Mog
    Mar 10, 2012 at 23:05

1 Answer 1

2

Looking at your new comments, to start a session all you need to do is:

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

   //Try retriving data:
   $session_id = $this->session->userdata('session_id');
   echo $session_id;
6
  • That's a good start, which... i already have. I'm trying to OUTPUT that session data (just to check)..
    – CodeTalk
    Mar 10, 2012 at 23:12
  • 1
    I have this in my app/config/config.php: $config['sess_expire_on_close'] = FALSE; $config['sess_encrypt_cookie'] = TRUE; $config['sess_use_database'] = TRUE; $config['sess_table_name'] = 'thetable'; $config['sess_match_ip'] = TRUE; $config['sess_match_useragent'] = TRUE;
    – CodeTalk
    Mar 10, 2012 at 23:15
  • The problem is, it isnt sending it to my database. I still have 0 rows.
    – CodeTalk
    Mar 10, 2012 at 23:16
  • When I access the page. Sorry for the multiple replies.
    – CodeTalk
    Mar 10, 2012 at 23:16
  • Updated my answer. Try using that without the database first to see that sessions is working. Then we will work on using a database as a backend.
    – F21
    Mar 10, 2012 at 23:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.