Reputation: 49104
I know that the default PHP session storage mechanism is a file, usually in tmp. And the session_id is carried in a cookie.
I want to also store my small amount of session data in the cookie too. (Like Rails does by default.)
Question: Is there a php library to handle this for me or do I need to roll my own using session_set_save_handler etc?
Added: Is just the CodeIgniter session class available?
Upvotes: 1
Views: 95
Reputation: 11
try this
$newdata = array(
'username' => 'johndoe',
'email' => '[email protected]',
'logged_in' => TRUE
);
$this->session->set_userdata($newdata);
$this->input->set_cookie($newdata);
Upvotes: -1
Reputation: 19662
What you need to ask yourself is why you are doing this. Provided that you provide your session ID, you can access any information present in the session itself. If you prefer to do it any other way, you will have to roll your own session system.
Here are a couple of points against what you have in mind:
redis
as your session manager. It is actually trivial to do.Assuming you still want to do it (are you really sure?), the answer is just to set another cookie. PHP session handlers are best not to mess around with due to the significant risk of throwing 500s all over the place if a change goes wrong. A second cookie is your best bet.
Upvotes: 2