简体   繁体   English

Scala Play框架丢弃Cookie问题

[英]Scala Play Framework Discarding Cookies questions

Hi I have some trouble using the Discarding Cookies function in the Play Framework for Scala 嗨,我在使用Scala的Play框架中的“丢弃Cookie”功能时遇到了一些麻烦

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. 我已将设置的cookie与域xyzcom一起使用,但我尝试丢弃该cookie,但我制作的DiscardingCookie具有相同的名称,但该域设置为yzcom。 Will the cookie be discarded? cookie会被丢弃吗? Or does the domain need to match 100% and would not work on subdomains in order for the cookie to be discarded. 还是该域需要匹配100%并且在子域上不起作用才能丢弃Cookie。

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? 另外,如果我在abc.com上设置了一个Cookie,但又被定向到另一个不存在该Cookie的页面,但是从新的重定向中,进行DiscardingCookie调用以丢弃不再存在的Cookie,那么该Cookie将被丢弃一次我回到abc.com吗? or Is that cookie out of scope since I am no longer on the correct domain 或该Cookie是否超出范围,因为我不再位于正确的域中

The DiscardingCookie case class definition goes as follows: DiscardingCookie案例类的定义如下:

/**
 * 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. 如您所见,这里有一个domain参数。 Just set it to Some("xyzcom") and it should work for you. 只需将其设置为Some("xyzcom") ,它就可以为您工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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