2013-06-12 52 views
5

有人可以向我解釋會話驅動程序嗎?搜索「laravel會話驅動程序」沒有透露任何關於不同類型的內容。我問,因爲下面的教程建議使用REST API的數組驅動程序,但我不知道爲什麼。教程:https://speakerdeck.com/akuzemchak/simple-api-development-with-laravel?slide=62Laravel會話驅動程序?

下面是從應用程序中的相關章節/配置/ session.php文件

/* 
|-------------------------------------------------------------------------- 
| Default Session Driver 
|-------------------------------------------------------------------------- 
| 
| This option controls the default session "driver" that will be used on 
| requests. By default, we will use the lightweight native driver but 
| you may specify any of the other wonderful drivers provided here. 
| 
| Supported: "native", "cookie", "database", "apc", 
|   "memcached", "redis", "array" 
| 
*/ 

'driver' => 'native', 

回答

14

這是很容易。驅動程序定義會話數據的存儲位置。

  • native - 會議將由內部PHP rutines
  • 處理
  • cookie - 會話將被存儲在cookie中
  • database - 會話將被存儲在數據庫中(默認情況下在表sessions
  • memcached/redis - 將其中一個守護進程用作會話存儲
  • array - 會話將存儲在普通數組中(它由處理)

array驅動意味着會話只有每個請求(PHP運行過程中存儲),之後,它就會消失:)

+0

謝謝!令人失望的是,這不是Laravel文檔中的任何地方。 –

+0

如何在laravel中使用redis/memcached驅動程序?我知道有一個驅動程序,我怎樣才能使用那個驅動程序? – Pars

+0

只需在配置文件('app/config/session.php')中更改驅動程序? – radmen

相關問題