Javascript DOM HTML Document cookie Property set

Introduction

The following code sets a cookie with the UserName set as Paul and an expiration date of 28 December, 2020:

View in separate window

<!DOCTYPE html> 

<html lang="en"> 
<head> 
    <script> 
        document.cookie = "UserName=Paul;expires=Tue, 28 Dec 2020 00:00:00;"; 
    </script> 
</head> //from w  ww  . j  a v a  2s  . c om
<body> 
    <p>This page just created a cookie</p> 
</body> 

</html> 



PreviousNext

Related