setcookie()和session_set_cookie_params()函数之间的区别 [英] Difference between setcookie() and session_set_cookie_params() functions

查看:82
本文介绍了setcookie()和session_set_cookie_params()函数之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解PHP函数setcookie()和session_set_cookie_params()之间的区别.

I am trying to understand the difference between PHP functions setcookie() and session_set_cookie_params().

看起来两个函数都执行相同的任务,但是setcookie()可以用于创建名称为&的cookie.值.

Looks like both functions are doing the same kind of tasks but setcookie() can be used to create cookie with name & value.

我试图理解PHP手册,但没有指出明显的区别.

I tried to understand PHP manuals but no clear differences pointed out in it.

谢谢

推荐答案

session_set_cookie_params(seconds)

session_set_cookie_params(seconds)

session_start()做两件事,它在服务器上创建一个临时文件以存储会话数据,还向用户的浏览器发送一个cookie.该cookie具有默认的过期时间,因此调用session_set_cookie_params(seconds)会将cookie的默认过期时间更改为您定义的时间.Cookie基本上将客户端指向他们的会话,因此需要访问该会话.

session_start() does two things, it creates a temporary file on the server of which to store session data, and also sends a cookie to the user's browser. This cookie has a default expiration time, so calling session_set_cookie_params(seconds) will change the default expiration time of the cookie to what you define. The cookie basically points the client to their session so it is required to access the session.

设置Cookie()

其中setcookie()函数定义要与其余HTTP标头一起发送的cookie.

where as setcookie() function defines a cookie to be sent along with the rest of the HTTP headers.

这篇关于setcookie()和session_set_cookie_params()函数之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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