每天laravel-20160821|CookieJar-1
2016-06-03 09:32
417 查看
namespace Illuminate\Cookie; use Illuminate\Support\Arr; use Symfony\Component\HttpFoundation\Cookie; use Illuminate\Contracts\Cookie\QueueingFactory as JarContract; // namespace about the c class CookieJar implements JarContract {// a Cookie Jar can be implements JarContract /** * The default path (if specified). * * @var string */ protected $path = '/';// set the default /** * The default domain (if specified). * * @var string */ protected $domain = null;// set default domain /** * The default secure setting (defaults to false). * * @var bool */ protected $secure = false;// default secure setting is null ,too bad /** * All of the cookies queued for sending. * * @var array */ protected $queued = [];// All of the cookies queued for sending. // queued for sending /** * Create a new cookie instance. * * @param string $name * @param string $value * @param int $minutes * @param string $path * @param string $domain * @param bool $secure * @param bool $httpOnly * @return \Symfony\Component\HttpFoundation\Cookie */ public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true) { list($path, $domain, $secure) = $this->getPathAndDomain($path, $domain, $secure);// a way to get list $time = ($minutes == 0) ? 0 : time() + ($minutes * 60);// has times set return new Cookie($name, $value, $time, $path, $domain, $secure, $httpOnly);// it is a Cookie // $name is key // $value is value // $time set the times // $path set path // $domain domain set // $secure secure set // $httpOnly httpOnly }// create or make the instance /** * Create a cookie that lasts "forever" (five years). * * @param string $name * @param string $value * @param string $path * @param string $domain * @param bool $secure * @param bool $httpOnly * @return \Symfony\Component\HttpFoundation\Cookie */ public function forever($name, $value, $path = null, $domain = null, $secure = false, $httpOnly = true) { return $this->make($name, $value, 2628000, $path, $domain, $secure, $httpOnly); }//Create a cookie that lasts "forever" // make is let set , throw set time to like to set the long time /** * Expire the given cookie. * * @param string $name * @param string $path * @param string $domain * @return \Symfony\Component\HttpFoundation\Cookie */ public function forget($name, $path = null, $domain = null) { return $this->make($name, null, -2628000, $path, $domain); }// set a bad time to forget it like delete /** * Determine if a cookie has been queued. * * @param string $key * @return bool */ public function hasQueued($key) { return ! is_null($this->queued($key)); }// if in this queued
相关文章推荐
- Yii2 如何使用事件
- (转载)Laravel学习笔记(一)安装配置开发环境
- js 与 php 时间戳的区别(毫秒与秒的计算方式)
- PHP常用函数封装
- ThinkPHP3.2.3实现分页的方法详解
- PHP学习笔记
- php获取数据库中数据,转成json数据
- 仿制smarty模板
- ThinkPHP3.2.3实现分页的方法详解
- PHP学习笔记之php文件操作
- PHP中读取文件的几个方法总结(推荐)
- PHP读取大文件末尾N行的高效方法推荐
- PHP常用文件操作函数和简单实例分析
- 九个很有用的PHP代码
- 基于Thinkphp开发的微商城
- PPTP服务器配置选项详解
- PHP导入Excel和导出数据为Excel文件
- php excel类 phpExcel使用方法介绍
- PHP之图像处理
- wamp通过phpMyAdmin修改登录密码