javascript cookie expire in 5 minutes

Solutions on MaxInterview for javascript cookie expire in 5 minutes by the best coders in the world

showing results for - "javascript cookie expire in 5 minutes"
Chiara
10 Oct 2017
1function createCookie(name,value,minutes) {
2    if (minutes) {
3        var date = new Date();
4        date.setTime(date.getTime()+(minutes*60*1000));
5        var expires = "; expires="+date.toGMTString();
6    } else {
7        var expires = "";
8    }
9    document.cookie = name+"="+value+expires+"; path=/";
10}
11
12createCookie("name", "value", 5)
13