Question

A few questions before I start my project in Codeigniter

  1. How long does Codeigniter store the data in a session table for a particular user. Is it as long as he is logged in?
  2. How can I modify the schema of the sessions table, I mean modifying the datatypes of the already present schema.
  3. Above question brings me to another one, can i change the Session table schema itself?
  4. Can I put in multiple cookies on the user's browser through a single session ID.
  5. How can I access the Session table through MYSQL console or is only accessible through the Codeigniter
  6. When the user logs in to my website again, how are the cookies from my website stored during the user's previous login get available to me for reading. How can i read them?

I know this might have been asked in bits and peices before but I wanted to have a clear picture in mind before I start my project. Thanks in advance

Was it helpful?

Solution

Codeigniter actually uses cookies for their sessions and you set the expiry time in the config.php file. I am not really sure how long it stores the actual database info (It isn't that long) and it will rewrite a new entry for a user when they log back in. So it's not really recommended to store critical data in the session table itself that isn't stored elsewhere. As long as their cookie persists the information could be restored but if they delete the cookie then you'll lose that data. If you need to store something permanently on a user don't use the session table.

I have no idea why you'd want to change the data types of the already present schema and honestly that would very likely screw up the system being able to store that data anyway without extending the session library. This seems like a huge headache to me for no real value.

Answered 3 already, don't add to the schema, create a new table if you need to store more info.

As to 4, 5 and 6. Since CI uses cookies for it's sessions anything you store in the session is a cookie and will be there until it expires or the user deletes their cookies.

Save info to the session:

$this->session->set_userdata('some_key','some value for that key');

Retrieve it:

$data = $this->session->userdata('some_key');

Read more here: http://ellislab.com/codeigniter/user-guide/libraries/sessions.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top