Jump to content

Cookies!


Amit20

Recommended Posts

Hello Everyone,

 

Now this is the issue which i m not understanding at all.

 

I m creating a cookie with folowing code

 

function setCookie(name,value){    
		 var ExpireDate = new Date ();
		 ExpireDate.setTime(ExpireDate.getTime() + (1 * 24 * 3600 * 1000));
		 document.cookie = name+"="+value+";expires="+ExpireDate.toGMTString()+"; path=/";	
    }

.

The point is cookie is being created but it does not show the expiry date, when i call document.cookie in firebug it gives me following output

 

"JSESSIONID=C5A6A2C72DC227F44D332B6FF194356F; Institute=4; Stream=3; Course=12".

 

But when i change the semi-colon with exclaimation mark in this sentence before the word "Expires"

 

document.cookie = name+"="+value+";expires="

 

as this

 

document.cookie = name+"="+value+"!expires="

 

then it gives me this output

"JSESSIONID=C5A6A2C72DC227F44D332B6FF194356F; Institute=5!expires=Tue, 08 Nov 2011 09:38:55 GMT; Stream=5!expires=Tue, 08 Nov 2011 09:38:56 GMT; Course=3!expires=Tue, 08 Nov 2011 09:38:57 GMT"

.

 

Can anyone please explain this behaviour!!!

 

Any help will be highly appreciated ;)

Link to comment
https://forums.phpfreaks.com/topic/250606-cookies/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.