我尝试使用kohana设置cookie。
我在application/controller/landing_page.php
<?php
class Landing_Page_Controller extends Controller {
public function index() {
// here i want to set cookie
}
}
?>
我在application/classes/cookie.php
<?php
class Cookie extends Kohana_Cookie {
// Set a new salt
public $salt = "some new better random salt phrase";
}
?>
如何在控制器中使用cookie类?
答案 0 :(得分:0)
默认情况下,存储cookie直到浏览器关闭。要使用特定的生命周期,请更改Cookie::$expiration
设置:
// Set cookies to expire after 1 week
Cookie::$expiration = 604800;
// Alternative to using raw integers, for better clarity
Cookie::$expiration = Date::WEEK;