Question: javascript cookie



Share on Google+Share on Google+

javascript cookie
1 Answer(s)      7 years ago
Posted in : Java Beginners
View Answers

August 17, 2009 at 4:59 PM

Hi Friend,

Try the following code to set the cookie and expire the cookie:

<script type="text/javascript">
function getCookie(cookieName){
if (document.cookie.length>0) {
start=document.cookie.indexOf(cookieName + "=");
if (start!=-1) {
start=start + cookieName.length+1;
if (end==-1) end=document.cookie.length;
return unescape(document.cookie.substring(start,end));
return "";
function setCookie(cookieName,value,expiredays){
var expireDate=new Date();
document.cookie=cookieName+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+expireDate.toGMTString());
function check(){
if (username!=null && username!="") {
alert('Welcome again '+username+'!');
else {
username=prompt('Enter your name:',"");
if (username!=null && username!="") {

<body onload="check()">



Related Tutorials/Questions & Answers:
javascript cookie - Java Beginners
javascript cookie  hi all, i wanted to know how to set expire attribute of cookie in javascript. heres the code : document.cookie = 'cookie2=Second_cookie'; expires=Mon, 17-Aug-09 04:42:00 GMT; path="/"'; whats wrong
Cookie in jsp
Cookie in jsp  Define Cookie in jsp ?   The cookie file is a file that resides on the client machine. It contains data passed from web... returns. The web site only has access to the part of the cookie file that represents
Persistent Cookie
Persistent Cookie  What Is a Persistent Cookie?   Hi friends, A persistent cookie is a cookie which is stored in a cookie file permanently... because users can open cookie files see the cookie values. Thanks
Clear cookie example
JavaScript. The code below has saveCookie() method that is used to create the cookie...; Clear cookie example </title> <script type="text/javascript">... Clear Cookie Example    
What Is a Persistent Cookie?
What Is a Persistent Cookie?  What Is a Persistent Cookie?. Explain
How to destroy a cookie?
How to destroy a cookie?  How to destroy a cookie
set cookie in jsp
set cookie in jsp  How set cookie in jsp ?   Cookie... cookie to identify the user in the next time visit.Example : <% Cookie cookie = new Cookie("ClientName","Roseindia"); cookie.setMaxAge(3600
How to reset a cookie?
How to reset a cookie?  How to reset a cookie
Setting Cookie
Setting Cookie  setcookie function is used for setting up a cookie. In the following example, if you use $_COOKIE command, you will view one cookie value, and if you see print_r ($_COOKIE), you will view all cookie value. We have
Cookie Handling - JSP-Servlet
Cookie Handling  Hi i am working on the Application in which i... on a per user setting (probably via a cookie). This would of course mean that when..."; //get the array of cookies. Cookie cookies [] = request.getCookies
Cookie methods in jsp
Cookie methods in jsp   Define cookie methods in jsp ?    Cookie methods : clone() getComment() getDomain() getMaxAge() getName() getPath() getSecure() getValue() getSecure() getVersion
Write cookie and session to textfile?
Write cookie and session to textfile?  I want to store all data from user submisstion into a textfile, include session and cookie. Thanks
Removing existing cookie in jsp
Removing existing cookie in jsp  How remove existing cookie in jsp ?   If you want to remove an existing cookie, you can use the method setMaxAge() of that cookie object to set its timeout to zero.Example <[email protected]
Delete Cookie
the cookie through setting session.  In the given example, we have set the value of cookie after one month of generating and before one hour of system date.  For deleteing the cookies, you will have to set the cookie expire time ahead
Is session depend on cookie ???
Is session depend on cookie ???  Since I created one session & as we say that session store at server side that means if I clear browser cookie... the cookie then my user logged out that means there is something behind session
problem with cookie - Struts
problem with cookie  struts cookies response - Hii, I am a beginner in struts..Well, I try to add username and group(or whatever) to a cookie but not able to access the cookie value in the next page after submitting the form
cookie and session dependency
cookie and session dependency  Hi, I am currently working on a project in travel domain. Throughout the application, we have not used cookie for session tracking but the case when browser cookie is disabled, session value differs
Differences between session and cookie
Differences between session and cookie  What are the differences between session and cookie?   Session is stored in server but cookie.... But it is limited in cookie. Session can store objects and cookies can store only
cookie - Java Beginners
cookie  i want to display cookie name and value on web page how? ...- cookie_name = "dataCookie"; var YouEntered; function putCookie... = document.cookie.indexOf(cookie_name); } else { index = -1
How can we destroy the cookie?
How can we destroy the cookie?   How can we destroy the cookie
cookie - JSP-Servlet
. I know it can be done through cookie but i dont knw how canx somebody post
Cookie Tag:
Cookie Tag:       bean:cookie Tag... cookie. This tag retrieve the value of the specified request cookie... attribute), and define  attribute of type Cookie or Cookie[] (depends
Jsp login with Cookie - JSP-Servlet
. If the cookie is present the username and password field should be automatically populated with the values from the cookie.   Hi Friend, Please
setMaxAge Cookie Java
setMaxAge Cookie Java In this tutorial you will learn how to use setMaxAge() of Cookie class in java setMaxAge() method sets the age of the cookie that how long it will be live. In other word we can say when a cookie will be expired
PHP Get Cookie
PHP Get Cookie The Cookies can be used to store identifiable information about... example (To know Cookie in details please visit our web page;), $inTwoMonths); f(isset($_COOKIE['lastVisit'])) $visit = $_COOKIE
PHP Cookie
PHP-Cookies Cookie is a very important part in Internet. PHP supports HTTP cookies. Using cookie we can store data into a remote browser. We can set... output is sent to the browser like header() function. Any cookie which
Cookie in Java EE 6
Cookie in Java EE 6 In this tutorial you will learn about the changes made in Cookie in Java EE 6. Cookie is an information that contains in a text form... to the server for uniquely identifying a client. This feature of cookie makes
How to manage cookie in between two JSP Pages
How to manage cookie in between two JSP Pages  How to manage cookie in between two JSP Pages   you can set cookies in response object e.g.response.addCookie(new Cookie("userName","Password")). Chandraprakash Sarathe
cookie creation without specifying the vaue - Java Beginners
cookie creation without specifying the vaue  how do we create cookies... for it.because my colleague said once cookie is created value will be assigned automatically.please give soln...  Hi friend, I have created cookie
JavaScript  clone JavaScript
Cookie Example to Store and Show only 10 values
Cookie Example to Store and Show only 10 values   ... last 10 Cookies value  This cookie example illustrates how you can manage cookie value in your JSP page. This example is saving and displaying cookies
Java Spring Hibernate Struts Training Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java Java Example Codes and Tutorials in 2017 How do I read a large file quickly in Java? Is learning Java worthwhile? How to create first Java Program? Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include?


Advertisement null