Hi Guest

MobileUser

1 HomePage 1 Jobs 1 WalkIn 1Articles  

Cat Exam

 :) Latest Topic
AJAX
VB.NET
SQL Query
UDDI
CLASS
JavaScript Questions
SharePoint Interview
SilverLight
WCF
general knowledge
 ASP.NET
 :) Hot Jobs
 
 :) Latest Articles


  

 


Javascript Code to Set Get and Delete Cookie?
Question Posted on 27 Jun 2022

Home >> JavaScript >> JavaScript Questions >> Javascript Code to Set Get and Delete Cookie?




Javascript Code to Set Get and Delete Cookie?
As we all are aware of Cookies definition and its important in programming languages. We can create by using document.cookie property like below:-

To set cookie we use below code:-
(1)document.cookie ="cookiename=cookievalue"

or we can set date of cookie expires in UTC/GMT format
(2)document.cookie = "cookiename=cookievalue; expires= Thu, 11 Aug 2022 20:00:00 UTC"

or we can even set path also in cookies
(3)document.cookie = "cookiename=cookievalue; expires= Thu, 11 Aug 2012 20:00:00 UTC; path=/ "

To Get the cookies the value we use below code
(4)var x = document.cookie

And to delete cookie we use below code
(5)document.cookie = "cookiename= ; expires = Thu, 01 Jan 1970 00:00:00 GMT"
0
0



 
 Input Your Comments Or suggestions(If Any)
 Name
 Email(optional)
 Comments


Other Important Questions
regular expression for credit card like VISA, MASTER, AMEX
How to remove item from dropdownlist in Javascript
Different Data Types in Javascript in 2015?
syntax to get dropdownlist text in javascript
The snippet that has to be used to check if “a” is not equal to “null” is _________






 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |