Setting sessions with an Ionic Framework App |
Hi,
I have a website using CodeIgniter as a server-side framework mainly for managing user sessions. In the website, when logging in a user, session is stored and there is no problem. Now I'm developing a Ionic app using the same API than the website use. The problem is that the session is not stablished. I'm trying to figure out why but do not find anything. My set session function is: Code: private function setSession($id, $email) { Code: public function isSessionActive() { In case the session variable 'user' exists, it indicates that there is a session active for the user. As I mentioned above, using this code, in the website it works fine, but when using it in an Ionic App, the function isSessionActive() always returns false. What's happening? Any help?
Hello!
When using Cordova (which is what ionic is build on), sessions do not always persist. For you to maintain a session, I'd recommend looking into using the app localstorage feature to maintain a session state. I've seen several different implementations but I recommend having an access token that you can reset/update that is sent securely via the header.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
(05-17-2016, 07:41 PM)albertleao Wrote: Hello! Hi, Is there any example I could use for sending tokens in header? Thanks.
If you use jQuery you can set your headers in the $.ajax method.
The documentation is here: http://api.jquery.com/jquery.ajax/
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
|
Welcome Guest, Not a member yet? Register Sign In |