Good Day!
Currently I have my application connected to a PHP server using MySQL as my backend service.
I wonder If someone knows on how could I have my session inside my application.
What i want to achieve is/are:
Have my LOG-IN Session Variables (Username or/and Password).
Use my Session Variables to display a certain user’s Profile details.
Please help me out. I want to start a session at every page whenever I logged in and destroy it as well after i logged out of my application.
Hi there
I would recommend looking into HTML5 local storage:
http://www.w3schools.com/html/html5_webstorage.asp
You can create a local storage object like so:
$window.localStorage['myStorageObject'] = JSON.stringify(myArray);
And retrieve it like so:
return JSON.parse($window.localStorage['myStorageObject'] || '[]');
You could create an object with your required properties on login and save the object in local storage. From there when you logout you can just destroy the local storage object.
I would recommend creating a factory with all your local storage operations and dependency injecting it into which ever controllers would require it.
Hope this help you
I use this for my project to save local data
I have used ionic’s factory to store the session variable. Got some idea from the link. Thanks!
Got some idea from that. But I have solved my problem using Angular’'s factory service. Thanks a lot!
sir can i ask you did you solve your problem? because i also want to have a login session and destroy it when i logout thank for your response
2 Likes
iam waiting too @Pajimola
Hi guys!
You might consider using Secure Storage to keep track of your login information, here are two links that I hope will help you.
Today I'm reviewing another Ionic Native feature, the Secure Storage wrapper. As the plugin docs explain, this is a plugin that allows for encrypted storage of sensitive data. It follows an API similar to that of WebStorage, with a few differences.
thx, but i realy apriciate if you have some example code, i feel more confident learn with actual code…
i already solve my problem…