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

Can I remove cookie by domain option? #12

Closed
Bombay opened this issue Jun 27, 2018 · 6 comments
Closed

Can I remove cookie by domain option? #12

Bombay opened this issue Jun 27, 2018 · 6 comments
Labels
question Further information is requested

Comments

@Bombay
Copy link

Bombay commented Jun 27, 2018

Hi.

Can I remove cookie by domain option?

I want to give remove option domain not path

Thank you for great module

@microcipcip
Copy link
Owner

Can you be more specific? Is the cookie in a different domain? For security reasons you can't delete a cookie from another domain. See this issue on stackoverflow.

@Bombay
Copy link
Author

Bombay commented Jun 27, 2018

My project created a cookie domain ".domain.com" to be intentionally shared on the same domain.
I want to use it once on a particular server with the same domain and try to delete it.

It is okay if it is an unreasonable request. Thank you very much for your quick reply.

@microcipcip
Copy link
Owner

If the server is different but the domain is the same you should be able to remove it. The only option you can specify when deleting is the path parameter, so if you get that right it should work. I am not sure if you can delete it if it is a subdomain though.

@microcipcip
Copy link
Owner

You can do anything that you are allowed to do with the node cookie script, because I just extend it.

@Bombay
Copy link
Author

Bombay commented Jun 27, 2018

I deleted it in the following way, but I wanted to integrate it using your plugin.

//in nuxt middleware
let cookieString = `${key} =; expire = ${expiredDate} domain = ${domain}`
if(isServer) res.setHeader('Set-Cookie', cookieString)
else document.cookie = cookieString

However, my case is a special case, and this method seems to be a security problem, so it does not seem to be necessary to add the function. Thanks for the answer.

@microcipcip
Copy link
Owner

Ok, I'll close it for now. I think the following should be the same of your code above.

cookies.set(key, '', {
  expires: expiredDate,
  domain: domain
})

@microcipcip microcipcip added the question Further information is requested label Jun 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants