I am new to ionic1 framework
and working on sidemenu ionic app
. Currently i am working on login functionality using web-service, its working fine. I am saving login information using sessionStorage
.
sessionStorage.setItem('loggedin_id', data.uid);
after that redirect to profile page using $state.go('app.profile', {}, { reload: true });
. In profile controller fetching information on the basis of loggedin_id
using $http.post
method.
At first time i am getting logged in user's detail on profile page, when i logout using sessionStorage.clear();
it redirect back to login page and than i am logged in again with another user and redirected to profile page it will not display current logged in user's detail it display old user's detail.
I have tried to alert loggedin_id
within login function it alert's correct id of users but not user's information. Please help me how to resolve this.
I have resolve this by using loggedin_id
as $stateParams
in profile route. Redirect after login like
$state.go('app.profile', {userID:sessionStorage.getItem('loggedin_id')},{location: "replace", reload: true});
At profile controller post userID as parameter of API. Now i am able to get proper information of logged in user.