190-804 Free Dumps Study Materials
Question 16: Hanna needs to write a function that will allow her to set a cookie and have the cookie expire when the
browser is closed. Which function below will meet these goals?
A.function setCookie(cName, cValue) {
document.cookie = cName + "=" + escape(cValue);}
B.function setCookie(cName, cValue) {var currDt = new Date();document.cookie = cName + ";" +
escape(cValue) + ";" + currDt.getTime() ;}
C.function setCookie(cName, cValue, cKeepDays) {var currDt = new Date();var expireDt = new Date();
expireDt.setTime( currDt.getTime() + (60*60*24*cKeepDays) );document.cookie = cName + "=" +
escape(cValue) + ";expireDt=" + expireDt.toGMT();}
D.function setCookie(cName, cValue, cKeepDays) {var expireDt = new Date();if (cKeepDays != null) {
expireDt.setTime( expireDt.getTime() + (1000*60*24*cKeepDays) );}
document.cookie = cName + "=" + escape(cValue) + ";expireDt=" + expireDt.toGMT();}
Correct Answer:A