JavaScript Reference/Javascript Properties/cookie

Материал из Web эксперт
Перейти к: навигация, поиск

"cookie" Example

    
<html>
<body>
<script language="JavaScript">
    myDate = new Date("12/22/2005 12:00 AM");
    document.cookie = "firstName=Joe; 
    expires=" + myDate.toString + ";";
</script>
<button onclick="alert(document.cookie);">See Document Cookie</button>
</body>
</html>



"cookie" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |document                                                      |
+----------------+--------------------------------------------------------------+



"cookie" Possible Values

Possible Values
A cookie can contain the following name-value pairs: 
expires  = (date), 
domain   = (domain name), 
path     = (usually the current directory)
secure   = (only secure environments can access the cookie).



"cookie" Syntax and Note

Note:
Read and write property. 
Sets the cookie value. 
    
Syntax:
    
document.cookie = value