I'm working with cookies in JS for the first time. I've done the backround reading and have what should be solid code. I'm not seeing the cookies when I test locally or with the transferred site on web host.
Code:[tt]
var PATH = "localhost/";
function set_cookie_value(cookie_name,cookie_value)
{
var cookie_expires = new Date();
cookie_expires = cookie_expires.getFullYear() + 1;
document.cookie = escape(cookie_name + "=" + cookie_value + ";expires=" + cookie_expires + ";path=" + PATH);
} //END: set_user_cookie[/tt]
My question(s):
Do I need one additional semicolon to close the PATH argument?
When testing locally should I change the path to "localhost/", if the path is being deliberately set with the cookie write?
If I let the browser default for path shouldn't this work both locally and on the internet host? (I'm setting the cookie at the index page at site root level, so there shouldn't be any problem with cookie visibility if it's set properly.
I am using an ISP "host your home page too in our members section" service with a funky "host.users/~myname/" URL. Does this have any effect since the domain is not really at my app level but up one?
Any insight into this would be much appreciated!!
Code:[tt]
var PATH = "localhost/";
function set_cookie_value(cookie_name,cookie_value)
{
var cookie_expires = new Date();
cookie_expires = cookie_expires.getFullYear() + 1;
document.cookie = escape(cookie_name + "=" + cookie_value + ";expires=" + cookie_expires + ";path=" + PATH);
} //END: set_user_cookie[/tt]
My question(s):
Do I need one additional semicolon to close the PATH argument?
When testing locally should I change the path to "localhost/", if the path is being deliberately set with the cookie write?
If I let the browser default for path shouldn't this work both locally and on the internet host? (I'm setting the cookie at the index page at site root level, so there shouldn't be any problem with cookie visibility if it's set properly.
I am using an ISP "host your home page too in our members section" service with a funky "host.users/~myname/" URL. Does this have any effect since the domain is not really at my app level but up one?
Any insight into this would be much appreciated!!