Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.remove does not remove cookies set on specific paths. #32

Open
p1100i opened this issue Sep 2, 2014 · 5 comments
Open

.remove does not remove cookies set on specific paths. #32

p1100i opened this issue Sep 2, 2014 · 5 comments

Comments

@p1100i
Copy link

p1100i commented Sep 2, 2014

Not sure if this is a feature or a bug, however if I set a cookie with a specific path, .remove does not have an effect on it, even doe' returning true.

Reproduction steps:

Navigate on a domain with a subpage like: /subpage/

ipCookie('x', 1, { path : '/subpage' });
ipCookie.remove('x') // returns true;
ipCookie('x') // returns 1, I was expecting it to be removed;

Extra info:

I know about the option ipCookie.remove('x', { path : '/subpage' }) however I was expecting from the return value of the remove above, to take effect on the /subpage path as well.

@bbrown
Copy link

bbrown commented Dec 4, 2014

Basically, it just sets the cookie's value to blank with an empty options object (by default) and then an expiration of -1. I extracted my set functionality into a service and then just pass into the set an empty string, so it'll use the same set of options exactly.

@idoo
Copy link

idoo commented Mar 21, 2015

Yes, this is not the behavior I expected :(

@ashish173
Copy link

.remove have got nothing to do with paths its not taken care of in the code.

cookieFun.remove = function (key, options) {
    var hasCookie = cookieFun(key) !== undefined;
        if (hasCookie) {
            if (!options) {
                options = {};
            }
            options.expires = -1;
            cookieFun(key, '', options);
        }
    return hasCookie;
};

it basically fetches all the cookies and then sets empty on the key of the cookie which we want to delete.

@pascalwinter
Copy link

I've noticed this issue as well. Because it is just setting the cookie value to to empty string, if the PATH and DOMAIN do not match the initial cookie, it will not be overwriting the correct cookie.

@kaleemullah360
Copy link

in angular 2 on calling remove all cookies only delete object cookies, the string cookies remain same. no values is over written and expiry is remain unchanged. I observe the issues right after specifying domain with loopback ip address in /etc/hosts. any solution ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants