Thinkphp5如何獲取進行會話控制

2021-08-20 07:47:02 字數 1105 閱讀 3461

1.use think\cookie;

採用think\cookie類提供cookie支援。

2.支援的引數及預設值如下:

// cookie 名稱字首

'prefix' => '',

// cookie 儲存時間

'expire' => 0,

// cookie 儲存路徑

'path' => '/',

// cookie 有效網域名稱

'domain' => '',

// cookie 啟用安全傳輸

'secure' => false,

// httponly設定

// 是否使用 setcookie

'setcookie' => true,

// 設定cookie 有效期為 3600秒

cookie::set('name','value',3600);

// 設定cookie 字首為think_

cookie::set('name','value',['prefix'=>'think_','expire'=>3600]);

// 支援陣列

cookie::set('name',[1,2,3]);

cookie::has('name');

// 判斷指定字首的cookie值是否存在

cookie::has('name','think_');

cookie::get('name');

// 獲取指定字首的cookie值

cookie::get('name','think_');

cookie獲取的時候也可以用$_cookie['名字'];進行獲取
刪除cookie

cookie::delete('name');

// 刪除指定字首的cookie

cookie::delete('name','think_');

thinkphp5如何使用layout

thinkphp5的layout和以前的版本有點差異。首先開啟配置檔案中的 template layout on true,layout name public layout layout on是開啟layout,layout name是可以配置layout的儲存位址 然後在你儲存layout位址的...

THINKPHP5獲取設定快取的例子

在thinkphp5中 快取的配置放在了config.php檔案中 如下 如何設定快取?可以使用靜態方法 cache set key value,3600 儲存快取 cache get key 獲取快取 也可以先例項化 再呼叫 cache model new cache 例項化快取模型 info c...

ThinkPHP5使用快取

cache 使用復合快取型別 type complex 預設使用的快取 default 驅動方式 type file 在這設定換人的快取方式 快取儲存目錄 path cache path,檔案快取 file 驅動方式 type file 設定不同的快取儲存目錄 path runtime path f...