CodeIgniter Forums

Full Version: How to get session data through CLI?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have a CI app and a nodejs APP which runs a socket server.
I would like to secure the connections to the socket by the CI's session.

Currently I'm sending back the session id (which I get on Nodejs side) to a session auth controller through CLI and "hacking" back
the data by the session ID.

Could you suggest a better solution for my problem?

Thanks,
Akos
Sessions in the context of CodeIgniter and in web development in general, are a concept that works under HTTP. They don't have any other purpose than maintaining state between HTTP requests and you shouldn't be dealing with them under CLI. In fact, the Session library will intentionally not load itself under CLI at all.
In CI use database driver for sessions and in nodejs app verify if user's cookie is in database
(04-07-2015, 01:41 PM)gadelat Wrote: [ -> ]In CI use database driver for sessions and in nodejs app verify if user's cookie is in database

Yes, you are right. I've just updated from CI 2x to 3 and with the new session handling I can solve this way.
Previously I couldn't because of the session encryption. Hence I decided to use CLI to decrypt the session data and send back to nodejs.

Thanks!
I'm trying to get the user data from DB from Nodejs and after I decode the buffer from the blob, I'm getting a long string. I guess this is an encrypted session. Is there a way to decrypt it in Nodejs? Soo I got back to the first problem I have headed with CI 2.