We want to store User's Authorization information in cookie which should not be lost upon refresh (F5) of browser.
We want to store authorization info in "permanent-cookie" in case user has opted for "Remember Me" check box at the time of log-on.
Set an expiration date for a cookie This can be done easily by adding expires=expirationDate in UTC separated by semicolon from the name=value, as seen in the following example: document. cookie = "username=Max Brown; expires=Wed, 05 Aug 2020 23:00:00 UTC"; document.
To set a cookie so it expires at the end of the browsing session, simply OMIT the expiration parameter altogether.
The Kind property of Expires is used to determine if the cookie is set to DateTimeKind.
What is the timeout of Cookie? The default time for a Cookie to expire is 30 minutes. The default Expires value for a cookie is not a static time, but it creates a Session cookie. This will stay active until the user closes their browser/clears their cookies.
This is possible in the 1.4.0 build of angular using the ngCookies
module:
https://docs.angularjs.org/api/ngCookies/service/$cookies
angular.module('cookiesExample', ['ngCookies']) .controller('ExampleController', ['$cookies', function($cookies) { // Find tomorrow's date. var expireDate = new Date(); expireDate.setDate(expireDate.getDate() + 1); // Setting a cookie $cookies.put('myFavorite', 'oatmeal', {'expires': expireDate}); }]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With