Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Jeanne Boyarsky
Ron McLeod
Sheriffs:
Paul Clapham
Liutauras Vilda
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
HTML Pages with CSS and JavaScript
What is wrong with my javascript!
forums UseR
Ranch Hand
Posts: 169
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hello Ranchers,
I am calling a javascript function to create a cookie. Here is my code:
setCookie('selection','hello world',36500, '/','testrepnet.valentair.com','true' ); function setCookie (name,value,expires,path,domain,secure) { document.cookie = name + "=" + escape (value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); alert ( "Cookie Testing6" + document.cookie + "!") }
This doesn't set the cookie 'selection' . What is wrong with the code above...
Thanks
forums UseR
Ranch Hand
Posts: 169
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I got it working finally. Here is the code that worked...
function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; }
There are no more "hours", it's centi-days. They say it's better, but this tiny ad says it's stupid:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Pre select a dropdown using cookie.
Cookie Path does not set properly
reg cookies and its syntax..
Loop through cookies and get value for a particular cookie name.
Reading the Domain Attribute of a Cookie in JS
More...