Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove Set-Cookie header from response in rails 3?

I have some actions that respond with static content. I also need them cached on client.

Similar question was asked in the past for rails 2

Is it possible to omit set-cookie header from the response in Rails 2.3?

like image 471
amitamb Avatar asked May 16 '11 20:05

amitamb


People also ask

What does set-cookie from response header do?

The Set-Cookie HTTP response header is used to send a cookie from the server to the user agent, so that the user agent can send it back to the server later. To send multiple cookies, multiple Set-Cookie headers should be sent in the same response.

Can a post request set a cookie?

Creating cookies. After receiving an HTTP request, a server can send one or more Set-Cookie headers with the response.

Is cookie in request header?

A cookie is an HTTP request header i.e. used in the requests sent by the user to the server.

How is the cookie set in the request?

The Set-Cookie header is sent by the server in response to an HTTP request, which is used to create a cookie on the user's system. The Cookie header is included by the client application with an HTTP request sent to a server, if there is a cookie that has a matching domain and path.


1 Answers

Use the built in option.

env['rack.session.options'][:skip] = true
or
request.session_options[:skip] = true

or in older versions use this

env['rack.session.options'][:defer] = true
or
request.session_options[:defer] = true

You can find the documentation for it here http://rack.rubyforge.org/doc/Rack/Session/Abstract/ID.html

like image 123
Darwin Avatar answered Sep 28 '22 16:09

Darwin