CodeIgniter Forums
How to get session data through CLI? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: How to get session data through CLI? (/thread-61307.html)



How to get session data through CLI? - pingwin - 04-07-2015

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


RE: How to get session data through CLI? - Narf - 04-07-2015

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.


RE: How to get session data through CLI? - gadelat - 04-07-2015

In CI use database driver for sessions and in nodejs app verify if user's cookie is in database


RE: How to get session data through CLI? - pingwin - 04-07-2015

(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!


RE: How to get session data through CLI? - pingwin - 04-08-2015

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.