search
Homephp教程php手册PHP的session存放路径及其配置session.save

PHP配置文件中session.save_path负责session文件的存放位置。 如果没有配置则不会生成session文件,如果配置的目录session.save_path = E:/ttt不存在,则会报错: Warning: session_start() [function.session-start]: open(E:/ttt\sess_e0b64760c92422d81c1



PHP配置文件中session.save_path负责session文件的存放位置。

如果没有配置则不会生成session文件,如果配置的目录session.save_path = "E:/ttt"不存在,则会报错:

Warning: session_start() [function.session-start]: open(E:/ttt\sess_e0b64760c92422d81c1d6202b66884f6, O_RDWR) failed: No such file or directory (2) in E:\APMServ5.2.6\www\htdocs\session\index.php on line 13
Warning: Unknown: open(E:/ttt\sess_e0b64760c92422d81c1d6202b66884f6, O_RDWR) failed: No such file or directory (2) in Unknown on line 0
Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (E:/ttt) in Unknown on line 0

所以,如果需要生成session文件,需要检查配置文件.如果没有配置目录,则请将php.ini中的“;session.save_path = "/tmp"” 改为“session.save_path = "E:/yourdir"”,并切记在E盘根目录下新建,名为yourdir的文件夹。

设置完成后需要重启服务,然后设置生效。

可以再php文件中测试,是否设置成功。
    $sessionpath = session_save_path();
    if (strpos ($sessionpath, ";") !== FALSE)
      $sessionpath = substr ($sessionpath, strpos ($sessionpath, ";")+1);

    //获取当前session的保存路径
    echo $sessionpath;



如果服务器是远程连接的,不在本地,不方便更改php配置文件,可以再程序中重置session目录。

    session_save_path('E:/ttt');

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

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.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

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.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use