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:
Tim Cooke
Campbell Ritchie
paul wheaton
Ron McLeod
Devaka Cooray
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Paul Clapham
Saloon Keepers:
Tim Holloway
Carey Brown
Piet Souris
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=/"; }
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
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...