Welcome Guest, Not a member yet? Register   Sign In
Basic session Problem
#5

[eluser]kurucu[/eluser]
You're putting a session_id into the session, which is a bit confusing for me as I'd expect CI to manage that for you. On the other hand, I have no idea what your application is doing!

However, going on a very thin amount of information, I think the point that has been missed is that you can store any amount of information in the session, against a key that you decide. CI manages matching up the correct session with the correct user, timeouts etc.

So, as pointed out by n0xie, you need to specify a key with which to store the data (called 'session_id' here). You can create as many items as you like by calling this function several times with different keys.

Code:
$this->session->set_userdata('session_id',$id);
$this->session->set_userdata('username', 'Fred');

Then, as shown in your own code, you retrieve the data by passing the key to the userdata() function.

Code:
$session_id = $this->session->userdata(‘session_id’); // correct! $session_id will be $id from before
$username = $this->session->userdata(‘username’); // $username will be 'Fred'

Note: Cookies are small and, despite their limits, will affect speed and security of your website depending on what you put in them. If you want to store any data structures or important information then I'd recommend setting up DB storage, which is quite well explained in the user guide.


Messages In This Thread
Basic session Problem - by El Forum - 09-03-2009, 03:01 AM
Basic session Problem - by El Forum - 09-03-2009, 03:02 AM
Basic session Problem - by El Forum - 09-03-2009, 03:19 AM
Basic session Problem - by El Forum - 09-03-2009, 03:28 AM
Basic session Problem - by El Forum - 09-03-2009, 06:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB