Search code examples
rubycookiesrest-client

How to get cookie details of the request in ruby using rest client


If I am making this get request using rest-client gem

https://www.google.co.in/

I want get the following details:-

  1. cookie
  2. expire date

Also i want to remove the cookie(like we do clear cookies in browser).

How can i do it?


Solution

  • You can do the following with rest-client:

    request = RestClient.get 'https://www.google.co.in/'
    

    then inspect the cookies you have with

    request.cookies
    

    but from what I've seen there's no expire date.

    To remove the cookies do the following

    request.cookies.clear