Kohana的请求cookie(),响应cookie()和Cookie类之间的区别? [英] Difference between the Kohana's Request cookie(), Response cookie() and the Cookie class?

查看:456
本文介绍了Kohana的请求cookie(),响应cookie()和Cookie类之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个程序处理cookie下kohana的HMVC结构,我发现Kohana有3种方式来获取/设置cookie。它们是



请求:: current() - > cookie()响应 - > cookie()和cookie类( Cookie :: set(),get()



而PHP有一个本地 setcookie()函数和 $ _ COOKIE



任何人都可以解释他们的分歧,以及他们应该分别使用的情况。

c> c> c> c >在同一对象上用于设置将要发送(或在初始请求的情况下已发送)的cookie以及请求的其余部分。 Request :: execute()期间,
Request :: cookie() c> $ _ COOKIE 。



c $ c> Request :: execute()将替换 setcookie()。 $ Request :: execute()后的
Response :: cookie()



Cookie帮助程序将签名您的Cookie,并由HTTP_Header用于将Cookie设置为您的初始请求对象中的Response对象(请参阅 Response :: send_headers() index.php )。
如果你试图编码HMVC安全,你可能不想直接使用它。


I'm working on a program dealing with cookies under the kohana's HMVC structure, and I find that Kohana has 3 ways to get/set the cookie. They are

Request::current()->cookie(), Response->cookie(), and the cookie class (Cookie::set(), get())

And PHP has a native setcookie() function and $_COOKIE to deal with cookies too.

Could anyone explain their differences and, what are the situations that they should be used respectively.

解决方案

Request::cookie() prior to calling Request::execute() on the same object is used to set the cookies that will be send (or have been sent in case of the initial request) along with the rest of the request. Request::cookie() during a Request::execute() will replace $_COOKIE.

Response::cookie() during a Request::execute() will replace setcookie(). Response::cookie() after a Request::execute() is used to get the cookies set back by the server.

The Cookie helper will sign your cookies and is used by HTTP_Header to set cookies set to the Response object in your initial Request object (see Response::send_headers() in index.php). You probably do not want to use it yourself directly if you are trying to code HMVC safe.

这篇关于Kohana的请求cookie(),响应cookie()和Cookie类之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆