JavaScript Reference/Javascript Properties/cookie

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

"cookie" Example

   <source lang="javascript">
   

<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>


     </source>
   
  


"cookie" is applied to

   <source lang="javascript">

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

     </source>
   
  


"cookie" Possible Values

   <source lang="javascript">

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).


     </source>
   
  


"cookie" Syntax and Note

   <source lang="javascript">

Note: Read and write property. Sets the cookie value.

Syntax:

document.cookie = value


     </source>