Sessions should be used whenever you want to preserve state between two different HTTP requests. You generally want to:
- Store session information on the server side (i.e. don't pass it all back and forth in cookies).
- Protect yourself against Cross Site Forgery Requests (CSFR) by generating a unique key for each request and validating the key when the request returns.
- Store only that information that will need to be accessed repeatedly. (Don't shove the 5,000+ results of the query you just ran for them into their session for example -- use caching instead.)
- Read about PHP's
$_SESSION
since CodeIgniter's session
is a wrapper around $_SESSION
.
- Understand how to maintain a secure session -- and know what CodeIgniter handles for you, and what you will need to do yourself.