简体   繁体   中英

How to set secure flag for cookies in play 2.4.x

I see this used to be set with a conf value for play 2.1.0

how to set secure flag for cookies inplay 2.1.0

But in 2.4.x I see that this has been moved to using HttpConfiguration instead, what needs to be done now to put the secure flag on cookies now?

You have multiple options to set the secure flag depending on which type of cookie you are talking about:

For the session cookie add the following in your application.conf file:

play {
   http {
       session = {
           secure = true
       }
   }
}

If you already configured the session cookie to be secure, all other cookies will be handled the same way unless you specify otherwise.

To change the configuration for regular cookies place the following in your application.conf file:

play.filters {
    cookie {
       secure = true
    }
}

See Filter reference.conf and Play reference.conf for all configuration options that you have for cookies and the session.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM