Cookie tutorial? | CodeIgniter Forums

Hi Cheese and welcome to the CI forums.

There isn’t (well, there might be, but I haven’t seen one) but it’s probably because it’s such a generic / straightforward thing that only uses a handful of simple techniques.

Rather than think in terms of cookies, just think instead in terms of CI’s Session functions.

At login (a form, a controller, a model to do the database user/pass check) you set some session data.

You then have a function somewhere – I prefer the MY_Controller approach, but a helper would work similarly well – to identify if a user is logged in, which it does by simply checking for the presence of that bit of session data.

At logout, you unset that session data.

Login and auth systems seems like they aught to be really complicated, but they really aren’t.

All you are really doing is storing a username and password, then getting it back from the user and making sure it matches something in the database.

Sessions make doing this once per ‘session’ really nice and easy. Manual session and cookie handling is only slightly annoying. It’s one bit of magic that its really nice to allow to ‘just work’, and learn the details as they hit you in the head

PHP Cookie Tutorials

Leave a Reply

Your email address will not be published. Required fields are marked *

To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image