27.1k views
1 vote
Var cookie = "username=mike2009";

cookie += "; max-age=" + 365 * 24 * 60 * 60;
cookie += "; path=/";
document.cookie = cookie;

(Refer to code example 15-1.) This code


creates a cookie that’s removed when the user closes the browser

creates a cookie that’s stored for 1 year

creates a cookie that’s stored for 365 minutes

does not create a cookie

1 Answer

4 votes

Answer:

creates a cookie that stored for 1 year.

Step-by-step explanation:

The code snippet creates a cookie with name mike2009.max-age is used to delete the cookie max-age takes the time in seconds so 365*24*60*60 is equal to 1 year.max-age attribute will delete the cookie after 1 year.In this code max-age is used but expires is used most often because it is supported by all of the browsers max-age is not supported by internet explorer,

User Yoselyn
by
4.4k points