What are cookies?

What is the best approach of removing cross domain cookies from one of the apps?

  • I've set 2 applications. Rails application and Rack one (Grape). I also configured the cookies so it'll be shared cross them. The Rails application is the a client application and the Rack one is for api. In the Rails app I set devise for authentication and in the api the application get authenticated via auth_token passed to the cookies. The problem is: I want to set a call in the api that would be able to remove and destroy the cookies in the api so it'll remove them in the app and the user session will be destroyed (sign out). I tried this by removing the cookies in the api by 'Chrome console' and I saw that the app signed out after it. please note that the cookies the Rails app set are 2: `_xxx_session` and `auth_token` and both are http only. How to remove the cookies from the api via Ruby? And will it be removed from the Rails app?

  • Answer:

    A simple way to remove cookies is to send the set-cookie response header with an expires date in the past. This way, you overwrite the name of the cookie for your sessions with an expires date in the past. Any subsequent requests made by the browser will not contain the expired cookie.

Tj Krusinski at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.