PHP 7.4.0 alpha 1 Released


(PHP 4, PHP 5, PHP 7)

session_save_pathLiefert und/oder setzt den aktuellen Speicherpfad der Session


session_save_path ([ string $path ] ) : string

session_save_path() gibt den Pfad des aktuellen Verzeichnisses zurück, das zum Speichern der Session-Daten verwendet wird.



Der Pfad der Session-Daten. Sofern angegeben, wird der Pfad, unter dem Daten gespeichert werden, entsprechend geändert. Zu diesem Zweck muss session_save_path() vor session_start() aufgerufen werden.


Unter manchen Betriebssystemen, wollen Sie vielleicht einen Pfad auf einem Dateisystem angeben, das sehr viele kleine Dateien effizient behandelt. Unter Linux, zum Beispiel, bietet reiserfs eventuell eine bessere Performance als ext2fs.


Gibt den Pfad des aktuellen Verzeichnisses zurück, das zum Speichern der Session-Daten verwendet wird.

Siehe auch

add a note add a note

User Contributed Notes 5 notes

mdibbets at outlook dot nospam
5 years ago
I made a folder next to the public html folder and placed these lines at the very first point in index.php

Location of session folder:


location of index.php


What I placed in index.php at line 0:

('session.save_path',realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/../session'));

This is the only solution that worked for me. Hope this helps someone.
ohcc at 163 dot com
1 year ago
If session.save_handler is set to files, on systems that have maximum path length limitations, when the session data file's path is too long, php may get you an error like "No such file or directory" and fails to start session, although the session-saving folder really exists on the disk.

You should:

1. Keep the session-saving folder's absolute path not too long
2. If you're with PHP 7.1+, don't set session.sid_length to a number too great, such as 255

I once got stuck with this problem on Windows and wasted hours to solve it.
alvaro at demogracia dot com
9 years ago
Debian does not use the default garbage collector for sessions. Instead, it sets session.gc_probability to zero and it runs a cron job to clean up old session data in the default directory.

As a result, if your site sets a custom location with session_save_path() you also need to set a value for session.gc_probability, e.g.:

ini_set('session.gc_probability', 1);

Otherwise, old files in '/home/' will never get removed!
sampathperera at hotmail dot com - Sri Lanka
11 years ago
Session on clustered web servers !

We had problem in PHP session handling with 2 web server cluster. Problem was one servers session data was not available in other server.

So I made a simple configuration in both server php.ini file. Changed session.save_path default value to shared folder on both servers (/mnt/session/).

It works for me. :)
hrushiemail at gmail dot com
4 months ago
('session.save_path',realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/tmp'));
ini_set('session.gc_probability', 1);


(for using above code create a tmp folder/directory in your directory)
To Top