This is a discussion on Creating Cookies within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; how can i create a cookie in java script? i basically want a function that does the equivilant of this ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| how can i create a cookie in java script? i basically want a function that does the equivilant of this in php Code: PHP Code:
setcookie('clicked', "TRUE", time()+99999)
what i intend is to have a link, and when it is clicked, the javascript create a cookie Code: HTML Code: <a href="http://www.google.com" onclick"CookieClick()">gooooogle</a> CookieClick() would then create the cookie |
| Sponsored Links |
| |||
| Hi function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure ) { var cookie_string = name + "=" + escape ( value ); if ( exp_y ) { var expires = new Date ( exp_y, exp_m, exp_d ); cookie_string += "; expires=" + expires.toGMTString(); } if ( path ) cookie_string += "; path=" + escape ( path ); if ( domain ) cookie_string += "; domain=" + escape ( domain ); if ( secure ) cookie_string += "; secure"; document.cookie = cookie_string; } set_cookie ( "username", "John Smith", 2003, 01, 15 ); Try like this
__________________ Shaalini.S ![]() Be the Best of Whatever you are... |
| |||
| Creating Cookies Example of Creating cookie: <html> <body> <script language="JavaScript"> myDate = new Date('12/22/2010 12:00 AM'); document.cookie = 'firstName=xxx; expires=' + myDate.toString + ';'; </script> <button onclick="alert(document.cookie);">Example of Cookie</button> </body> </html> ThankQ KiruthikaSambandam |
![]() |
| Thread Tools | |
| Display Modes | |
| |
LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/html-css-javascript-coding-techniques/263-creating-cookies.html | |||
| Posted By | For | Type | Date |
| DiscussWeb IT Community - Technical Support and Technology Discussions | This thread | Refback | 11-21-2007 09:09 PM |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating Games | aicram | Game Development | 5 | 11-05-2008 08:41 PM |
| Cookies | nhoj | Java Server Pages (JSP) | 4 | 09-29-2008 12:32 AM |
| PDF Creating in PHP | saravanan | PHP Programming | 20 | 04-08-2008 07:15 AM |
| Creating password | chocoguy | Perl | 0 | 01-01-2008 12:53 AM |
| Cookies | ragavraj | PHP Programming | 4 | 11-01-2007 12:48 PM |