Welcome Guest, Not a member yet? Register   Sign In
Using CI_Session outside CI
#1

[eluser]Unknown[/eluser]
Hi, I'm using CI 1.6.3 and I store user login data (user id, etc.) using CI's session class. It's good, but now I need to grab the login data from the cookie to integrate with a forum.

It seems that the CI session class references the active controller using get_instance. Is it possible to use it outside CI?

I suppose I can always grab the data out of the cookie and unserialize it if it's not encrypted, but that doesn't handle the cases handled in sess_run (last activity & session id updating, hash verification), plus I'd rather use prewritten, pretested code Smile.

Thanks,
William.
#2

[eluser]TheFuzzy0ne[/eluser]
I think I'd like to see a way of accessing the functionality of CodeIgniter without having to load a controller.

If the data is encrypted, you can decrypt is easily enough by using the encryption key that your specified in your configuration file. In you situation, I think I would create a custom Session class for the forum that works in a similar fashion to the CodeIgniter Session class. It would know how to decrypt the cookie and how to retrieve values. You could simply start with the original CodeIgniter Session class, and fix the bits that reference the CI super object.




Theme © iAndrew 2016 - Forum software by © MyBB