December 2013
Intermediate to advanced
384 pages
9h 54m
English
The following code shows a full example of setting and getting cookies. When the code is run, two cookies are set: one for name and the other for language. The cookies are then retrieved from the browser and written to the web page, as shown in Figure 3.2.
01 <html> 02 <head> 03 <title>Python Phrasebook</title> 04 <meta charset="utf-8" /> 05 <script type="text/javascript" 06 src="../js/jquery-2.0.3.min.js"></script> 07 <script> 08 function setCookie(name, value, days) { 09 var date = new Date(); 10 date.setTime(date.getTime()+(days*24*60*60*1000)); 11 var expires = "; expires="+date.toGMTString (); 12 document.cookie = name + "=" + value + ...
Read now
Unlock full access