session_save_path

(PHP 4, PHP 5, PHP 7)

session_save_path현재 세션 저장 경로를 얻거나 설정

설명

string session_save_path ([ string $path ] )

session_save_path()는 세션 데이터를 저장하는 현재 디렉토리 경로를 반환합니다.

인수

path

세션 데이터 경로. 지정하면, 데이터를 저장하는 경로가 변경됩니다. 이를 위해서는 session_start() 전에 session_save_path()를 호출해야 합니다.

Note:

몇몇 OS에서, 수많은 작은 파일을 효율적으로 다루는 파일시스템 경로로 지정할 수 있습니다. 예를 들어, 리눅스에서 reiserfs는 ext2fs보다 좋은 성능을 제공합니다.

반환값

데이터 저장에 사용하는 현재 디렉토리 경로를 반환합니다.

참고

add a note add a note

User Contributed Notes 5 notes

up
51
mdibbets at outlook dot nospam
6 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:

/domains/account/session

location of index.php

/domains/account/public_html/index.php

What I placed in index.php at line 0:

<?php
ini_set
('session.save_path',realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/../session'));
session_start();

This is the only solution that worked for me. Hope this helps someone.
up
11
ohcc at 163 dot com
2 years 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.
up
30
alvaro at demogracia dot com
10 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.:

<?php
session_save_path
('/home/example.com/sessions');
ini_set('session.gc_probability', 1);
?>

Otherwise, old files in '/home/example.com/sessions' will never get removed!
up
13
sampathperera at hotmail dot com - Sri Lanka
12 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. :)
up
-1
hrushiemail at gmail dot com
1 year ago
<?php
ini_set
('session.save_path',realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/tmp'));
ini_set('session.gc_probability', 1);
session_start();

?>

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