1. Session Class – CI User Guide
The Session class permits you maintain a user’s “state” and track their activity while they browse your site. The Session class stores session information for each user as serialized (and optionally encrypted) data in a cookie. It can also store the session data in a database table for added security, as this permits the session ID in the user’s cookie to be matched against the stored session ID. By default only the cookie is saved. If you choose to use the database option you’ll need to create the session table as indicated below.
When we build web application with user authentification, the application must have user login/logout or signin/signout or whatever you called it, then the system must have user logged feature to check whether the user is logged in or logged out. Session is the most common way to checking it.
we quietly added some nice enhancements to the CodeIgniter Session library that I wanted to mention.
For a project we’re working on, we have the need to access CodeIgniter session data outside of our CI installation, more specifically for a WordPress installation. CodeIgniter, as most developers should already know, stores it’s session data in a database and uses a cookie to refer to the data, as opposed to storing this data inside of the PHP default $_SESSION superglobal.
what/where is the best way to check for user sessions in CI? I dont want to put session checks in every controller. That is already code smell. Been thinking of a good solution for a while now and this is what I came up with.
The Idea is for all my controllers to inherit from a single parent controller. This way I can put the session check inside the parent controller then all other child classes will inherit this check.
If you know any article that explains even better then please share with us.