search
Homephp教程php手册PHP中常见的Session问题

PHP中常见的Session问题

Jun 13, 2016 am 09:59 AM
phpsessionhowWillcommonExpectofset upquestion

1,如何设置长生命期的session ?
将 session.cookie_lifetime ,session.gc_maxlifetime 的时间设置长一点。

2,为什么初始化session的时候报错?
a,检查session文件的存储路径,路径是否对,操作权限是否够
b,检查session初始化之前是否有html 内容输出

3,客户端在禁止使用cookie的时候,session会有影响吗?
当客户端的cookie拒绝使用的情况下。将会带来很多的一些的不方便:
php 会自动在页面的链接和表单等地方添加sessionId参数。以保证会话的
继续,但是这个时候,在一个浏览器上多次手工输入一样地址,session
会认作为多次会话而不是一次。

4,为什么我的session 过几分钟就失效了?
1,检查浏览器的cookie 是否启用,假如没有启用的话检查
系统是否答应使用url传递sessionID,最后检查url_rewriter.tags设置
2,检查session的垃圾标识时间,和回收概率

5,如何将我的session 存储在数据库内?
利用session_set_save_handler("open", "close", "read", "write", "destroy", "gc")
定制自己的处理方式。

6,如何利用session 得到当前的用户数量和列表?
假如将session存储在数据库内,就会很轻易实现,但是不管用什么
方式得到的数据不一定是精确数据。

7,为什么我填写的表单在后退之后内容就不见了?
检查脚本内有没有初始化session的动作,假如有的话,使用:
session_cache_limiter('private, must-revalidate');

6,如何利用session来控制网页的缓存?
调整session.cache_limiter ,session.cache_expire

8,我用session治理会话,假如同一个帐户在两台机器上同时登陆会有影响吗?
不会有影响。因为这是两个sessionID.也就是说服务器上有两个session文件
来保证各自的会话。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft