Multi Session library |
[eluser]jegbagus[/eluser]
Cart library is work really great, but i used to separate login session (use CI session library) with my cart (using cookies). but now they were placed in the one session that have the same expire time. the problem come when i need my session library expire earlier than cart library (cart library actually never be expire) Here i create library that separate life time of your group of session (if you mention my earlier post, i always have a problem with many session life time). preparation : - add library in your library folder and named it Multi_Session.php - extend session library and save it to library folder and named it My_Session.php - it is better to set your session expire to 0 at your config file. Code: $config['sess_expiration'] = 0; How to Use : Loading library : Code: $this->load->library('Multi_Session'); Set Session Data : You must at least set expire session time Code: $newdata = array( Read Session Data : Code: $this->multi_session->user_data('login','name') Unset Session Data : Code: $this->multi_session->unset_userdata('login','name') Code: $this->multi_session->unset_userdata('login') Update Session Data : Code: $this->multi_session->update_userdata('login','name','anotheruser'); Multi_Session.php Code: <?php if(!defined('BASEPATH')) exit("Hack attempt?");
[eluser]jegbagus[/eluser]
My_Session.php Code: <?php if(!defined('BASEPATH')) exit("Hack attempt?");
[eluser]BrianDHall[/eluser]
Wow, this is actually a very cool idea. Thanks for contributing your code!
[eluser]NikhilSukul[/eluser]
Will it also handles session per tab setup if you want in FF?
[eluser]bfj[/eluser]
Actually, you don't need to create an additional library for multiple session (session cookie) management. You can use CI's built in session class by just loading multiple session object instances with different names to create separate sessions and using them, where any of those objects are needed. Something like this: Code: // Create session1 - session1 - expires in 1 hour; - session2 - expires in 2 hours.
[eluser]SlasHo[/eluser]
Hi, is there any way to use, Session.php from 1.7.3 in a CI 1.5.4 ?? I need to use the example above in 1.5.4 (multiple cookies) any ideas?? |
Welcome Guest, Not a member yet? Register Sign In |