![]() |
AE Session : Yet Another Session Library - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: AE Session : Yet Another Session Library (/showthread.php?tid=7221) |
AE Session : Yet Another Session Library - El Forum - 03-30-2008 [eluser]Aea[/eluser] It feels a little bit awkward releasing yet another session library, especially after another one was posted within the week. This code originates from some Native Session Library modifications I made a few weeks ago, but hadn't thought to release until now. Unlike (some of the) other session libraries, this code is: - Extremely Lightweight - Relies on Native $_SESSION variables - Relies on PHP5 Functions Offers: - Protection against Session Fixation - Efficient Handling of Flash Session Data AE Session is only compatible with PHP5, however you can drop in Native Session's regeneration function and it should work. I work only with PHP5 thus there was no need to use the round-about PHP4 style session regeneration. This library doesn't do everything, in fact it does very few things (see KNDB Session if you need a powerful Session Library), but it does them very well. Without further ado: Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); Installation and Usage Drop the code named as Session.php into applications/libraries Edit your config.php... Code: $config['sess_expiration'] = 300; Five minutes seems like a good regeneration interval, you may adjust this based on your requirements. All other session variables are unused, and you may comment them out. Setting and retrieving session data is done using $_SESSION['key'], you can at any time convert data to flash data and back, here's how this works... Code: $_SESSION['my_data'] = ...; # corresponds to how many pages you want this data to persist. If you want to remove the flash data limit, simply unset the my_data:flash key, and it'll return to being persistent session data. Enjoy, and feel free to improve on my implementation. AE Session : Yet Another Session Library - El Forum - 03-30-2008 [eluser]Jamie Rumbelow[/eluser] Pretty nice. But I prefer to use CI's built in library. But I do miss classic $_SESSION variables. Actually, I might have a go at implimenting this in Pheonix - I'm aiming at having different ways of sessions and stuff. |