Categories
Ruby On Rails

IE + iframe + cookies

After spending lots of hours building a system for a client, using Ruby on Rails, everything was deployed and worked perfect… until IE came along that is.

The customer had iframed the project into their current website, and since the user had to sign in to the new project using an iframe, IE began to give all kinds of errors.
The direct link worked like a charm, but IE seems to want more!

I stumpled upon an answer on stackoverflow – where else? (link to stackoverflow answer)
It simply states, that if you want to use cookies in iframes, using IE, you need to add a P3P header.
And it worked!

Rails howto

To do this in Rails, simply open up “application_controller.rb” and add a new filter:
before_filter :set_pthreep

The code for the filter is added in the private section of the application_controller.rb file:
def set_pthreep
response.headers['P3P']= 'CP="Potato"'
end

And that’s all there is to it.

Leave a Reply

Your email address will not be published. Required fields are marked *