Cookie.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2018 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. namespace think\worker;
  12. use think\Cookie as BaseCookie;
  13. use Workerman\Protocols\Http as WorkerHttp;
  14. /**
  15. * Workerman Cookie类
  16. */
  17. class Cookie extends BaseCookie
  18. {
  19. /**
  20. * 保存Cookie
  21. * @access public
  22. * @param string $name cookie名称
  23. * @param string $value cookie值
  24. * @param int $expire cookie过期时间
  25. * @param string $path 有效的服务器路径
  26. * @param string $domain 有效域名/子域名
  27. * @param bool $secure 是否仅仅通过HTTPS
  28. * @param bool $httponly 仅可通过HTTP访问
  29. * @param string $samesite 防止CSRF攻击和用户追踪
  30. * @return void
  31. */
  32. protected function saveCookie(string $name, string $value, int $expire, string $path, string $domain, bool $secure, bool $httponly, string $samesite): void
  33. {
  34. WorkerHttp::setCookie($name, $value, $expire, $path, $domain, $secure, $httponly);
  35. }
  36. }