javascript
Set a cookie for whole domain in javascript
In this post, we are going to describe the methods that can be used to set a cookie for the whole website or domain and not for some specific page.
document.cookie = "cookie_name=cookie_value;path=/";
When we set a cookie in javascript using document.cookie, it set the cookie for that specific page on which we are running the script. To set the cookie for the entire site we use path keyword with cookie name and cookie value and assign it '/' value.
Was this helpful?
Similar Posts
- Set a cookie that never expires using Javascript
- Javascript function to get cookie value by name
- Get and set storage in chrome extension
- Set default date in Jquery UI datepicker
- Convert all characters to lowercase using toLowerCase() method in javascript
- Array.forEach() in javascript
- Replace characters globally Javascript