I have one login application and here i need to use session and cookies using angular.js.I am explaining my code below.
loginController.js:
var loginAdmin=angular.module('Channabasavashwara');
loginAdmin.controller('loginController',function($scope,$http,$location){
$scope.user_name = '';
$scope.user_pass = '';
$scope.user_login=function(){
if($scope.user_name==''){
alert('user name filed should not keep blank');
}else if($scope.user_pass==''){
alert('password filed should not keep blank');
}else{
var userData={'user_name':$scope.user_name,'user_pass':$scope.user_pass};
console.log('user',userData);
$http({
method: 'POST',
url: "php/Login/login.php",
data: userData,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).then(function successCallback(response){
console.log('response',response);
alert(response.data['msg']);
$location.path('dashboard');
},function errorCallback(response) {
alert(response.data['msg']);
});
}
}
});
Here my requirement is when user will logged in successfully the session will store and at the time of logout it will move.Similarly cookies will store with some expiration time(lets say 10 min) after the time will expire it will logout automatically with one alert message.Please help me.