Location for session files in Apache/PHP

前端 未结 9 1184
醉梦人生
醉梦人生 2020-12-08 03:32

What is the default location of session files on an installation of Apache/PHP on Ubuntu 10.10?

相关标签:
9条回答
  • 2020-12-08 04:17

    Another common default location besides /tmp/ is /var/lib/php5/

    0 讨论(0)
  • 2020-12-08 04:29

    The only surefire option to find the current session.save_path value is always to check with phpinfo() in exactly the environment where you want to find out the session storage directory.

    Reason: there can be all sorts of things that change session.save_path, either by overriding the php.ini value or by setting it at runtime with ini_set('session.save_path','/path/to/folder');. For example, web server management panels like ISPConfig, Plesk etc. often adapt this to give each website its own directory with session files.

    0 讨论(0)
  • 2020-12-08 04:31

    First check the value of session.save_path using ini_get('session.save_path') or phpinfo(). If that is non-empty, then it will show where the session files are saved. In many scenarios it is empty by default, in which case read on:

    On Ubuntu or Debian machines, if session.save_path is not set, then session files are saved in /var/lib/php5.

    On RHEL and CentOS systems, if session.save_path is not set, session files will be saved in /var/lib/php/session

    I think that if you compile PHP from source, then when session.save_path is not set, session files will be saved in /tmp (I have not tested this myself though).

    0 讨论(0)
提交回复
热议问题