JS Coding Questions Logo
JS Coding Questions
#40💼 Interview💻 Code

What are the options in a cookie

Advertisement

728x90

There are few below options available for a cookie,

1. By default, the cookie is deleted when the browser is closed but you can change this behavior by setting expiry date (in UTC time).

javascript
1document.cookie = "username=John; expires=Sat, 8 Jun 2019 12:00:00 UTC";

2. By default, the cookie belongs to a current page. But you can tell the browser what path the cookie belongs to using a path parameter.

javascript
1document.cookie = "username=John; path=/services";

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 42

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
40of476