javascript - Can't remove cookies, which are generated by PHP -
here how create cookie in php , javascript
php, before loading page, first create cookie via php .
setcookie('my_key', $value, 0,admin_cookie_path);
javascript. i'm using jquery cookie plugin.
when dropdown changed, change cookie value.
jquery.cookie("my_key", selected);
in google chrome, works expected.
the value of my_key
cookie altered when dropdown changed.
in firefox, generates identical cookie.
yes, identical my_key
cookie generated php:
same name, same expire(browser session), same domain, same path, same httponly(blank), same security(blank)
the difference new cookie set new value.
i try jquery.removecookie('my_key')
can delete new cookie.
i'm not sure if bug of firefox, or did wrong. but, truly, annoying issue.
update 1: it's true didn't specific path in javascript , right can change cookie generated php when set path. still not able delete cookie via js.
fyi, i'm able delete cookies in php can't delete them in js.
answer inspired spokey , mightypork:
1, set path
jquery.cookie
2, use
jquery.cookie("my_key", '',{expires: -1,path:'/admin'});
instead ofjquery.removecookie
update:
i did use jquery.removecookie('my_key',{path:'/admin'}) last night not working. , try again morning, it's working. maybe tired last night.
conclusion
the whole thing path. think, tests, perhaps, firefox has more strict standards google chrome cookie manipulation.
Comments
Post a Comment