Get best price on Prepaid Cheapest Smartphone | ||||||||||||
|
||||||||||||
|
JavaScript: How to Work With CookiesCookies: Putting It All Together & Summary (Part 5)Our cookie tutorial used JavaScript and HTML forms to create and work with a cookie file. In actual use, you would call your cookie functions when your page is loaded. Put the JavaScript cookie functions at the top of your file like in the previous pages of this tutorial. After your HTML BODY tag, call the relevant cookie function. Saving a Cookie
<script language="JavaScript"><!--
var exp = new Date(); //create new date object exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * 30)); //set it 30 days ahead setCookie("myCookie","it is crunchy", exp); //save the cookie //--> </script> Retrieving the Cookie
<script language="JavaScript"><!--
getCookie("myCookie"); //--> </script> For debugging, you can print out the cookie to your browser:
<script language="JavaScript"><!--
document.write(getCookie("myCookie")); //--> </script> Deleting the Cookie
<script language="JavaScript"><!--
delCookie("myCookie"); //--> </script> Summary of Using JavaScript to Save, Retrieve and Delete a CookieThere you have it. This wasnt the most spectacular example of using a cookie, but this is meant to get you started. Understand the basics of working with cookies and then you can build from here and use cookies in more sophisticated and innovative ways. Have fun with it and hope it helps. Return to First Page of Cookie Tutorial
Related Links:
Cookie Central -- a site devoted completely to information about cookies.
|
privacy policy || © 1997-2016. astonishinc.com All Rights Reserved. |