什么是php中的会话和cookie,它们存储在哪里? [英] What are sessions and cookies in php and where are they stored?

查看:218
本文介绍了什么是php中的会话和cookie,它们存储在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是php中的会话和cookie,它们存储在哪里?

What are sessions and cookies in php and where are they stored?

我搜索了,但找不到确切答案.

I searched but I can't find the exact answer.

推荐答案

Cookie存储在浏览器中,而不存储在PHP中.您可以通过在$_COOKIE['cookiename']中查找来获取浏览器发送的cookie,但据我所知,您无法设置此类cookie –您需要使用setCookie(),或者可能是header('Set-cookie: ...').

Cookies are stored in the browser, not in PHP. You can get the cookies the browser sent by looking in $_COOKIE['cookiename'], but as far as i know you can't set cookies like that -- you need to use setCookie(), or possibly header('Set-cookie: ...').

会话可以存储在任何地方,但是大多数情况下它们只是服务器文件系统中的文件;您的php.ini(或ini_get()函数)可能有助于找出位置.试试:

The sessions can be stored anywhere, but they're most often just files on your server's filesystem; your php.ini (or the ini_get() function) would probably be helpful in finding out where. Try:

$session_file_name = ini_get('session.save_path')."/sess_".session_id();

这篇关于什么是php中的会话和cookie,它们存储在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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