I am using angularjs cookies.
https://docs.angularjs.org/api/ngCookies/service/$cookies
I am using $cookies
to store username and password. I know that is bad practice but put that aside for the moment. I want the user to log in once and never need to do it again unless the cookies are cleared. However, the problem is that after the chrome browser is closed, the user has to log in again next time he visits the web page because the cookies are no longer present. I want the cookies to never expire.
Here is the relevant code written in a factory;
.factory('AuthenticationService',
['$base64', '$http', '$cookies', '$rootScope', '$timeout', 'configuration',
function ($base64, $http, $cookies, $rootScope, $timeout, $configuration) {
var service = {};
service.Login = function (username, password, callback) {
//login code
};
service.SetCredentials = function (username, password) {
var authdata = $base64.encode(username + ':' + password);
$http.defaults.headers.common['Authorization'] = 'Basic ' + authdata;
$cookies.put('username', username);
$cookies.put('authdata', authdata);
};
return service;
}])
How to make the cookies to never expire and remain there even after the browser is closed?