For a specific controller action I want to turn off cookies. I've tried to remove the cookie Map, but that doesn't seem to work. I need to completely remove all response headers except my own.
Any ideas?
For a specific controller action I want to turn off cookies. I've tried to remove the cookie Map, but that doesn't seem to work. I need to completely remove all response headers except my own.
Any ideas?
I managed to wrap the response with a wrapper with
response.current.set(new CookieLessResponseWrapper(response.current()))
. Works ok for me.Here is the code for the Response wrapper if anyone is interested.
I found this solution when Googling this problem. It does the same thinng you try, removing cookies map, but it is done in an method which is annotated with
@Finally
.I believe cookies map is filled after
render()
but before any@Finally
annotated class.Credits to Alex Jarvis on Google Groups, code is copied for reference:
Usage: For any controller you want to be "cookieless" annotate it with
(Tested in Play 1.2.5)
Have in mind that the Session is a Cookie. I don't believe that you can remove it.
You should be able to clear all headers, in your action, with:
How about use discarding the whole session for each request as a workaround?
Discarding the whole session
https://www.playframework.com/documentation/2.3.x/ScalaSessionFlash#Discarding-the-whole-session