Hi I have some trouble using the Discarding Cookies function in the Play Framework for Scala
I have used set cookies with the domain xyzcom I am trying to discard the cookie but the DiscardingCookie I made has the same name, but the domain is set to yzcom. Will the cookie be discarded? Or does the domain need to match 100% and would not work on subdomains in order for the cookie to be discarded.
Also if I set a cookie on abc.com but get directed to another page where the cookie does not exist, but then from the new redirect, make a DiscardingCookie call to discard the cookie that is not there anymore, will that cookie be discarded once I return to abc.com? or Is that cookie out of scope since I am no longer on the correct domain
The DiscardingCookie
case class definition goes as follows:
/**
* A cookie to be discarded. This contains only the data necessary for discarding a cookie.
*
* @param name the name of the cookie to discard
* @param path the path of the cookie, defaults to the root path
* @param domain the cookie domain
* @param secure whether this cookie is secured
*/
case class DiscardingCookie(name: String, path: String = "/", domain: Option[String] = None, secure: Boolean = false) {
def toCookie = Cookie(name, "", Some(-86400), path, domain, secure)
}
As you can see there is a domain
parameter. Just set it to Some("xyzcom")
and it should work for you.
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.