CentOS 7 PHP7 启用session扩展
2023-01-17 14:11 投稿人:网络编辑
配置指南:
http://php.net/manual/zh/refs.basic.session.php
http://php.net/manual/zh/session.configuration.php
使用命令:
php -ire>找到打印输出session块的信息
session Session Support => enabled Registered save handlers => files user Registered serializer handlers => php_serialize php php_binary Directive => Local Value => Master Value session.auto_start => Off => Off session.cache_expire => 180 => 180 session.cache_limiter => nocache => nocache session.cookie_domain => no value => no value session.cookie_httponly => Off => Off session.cookie_lifetime => 0 => 0 session.cookie_path => / => / session.cookie_secure => Off => Off session.gc_divisor => 100 => 100 session.gc_maxlifetime => 1440 => 1440 session.gc_probability => 1 => 1 session.lazy_write => On => On session.name => PHPSESSID => PHPSESSID session.referer_check => no value => no value session.save_handler => files => files session.save_path => no value => no value session.serialize_handler => php => php session.sid_bits_per_character => 4 => 4 session.sid_length => 32 => 32 session.upload_progress.cleanup => On => On session.upload_progress.enabled => On => On session.upload_progress.freq => 1% => 1% session.upload_progress.min_freq => 1 => 1 session.upload_progress.name => PHP_SESSION_UPLOAD_PROGRESS => PHP_SESSION_UPLOAD_PROGRESS session.upload_progress.prefix => upload_progress_ => upload_progress_ session.use_cookies => On => On session.use_only_cookies => On => On session.use_strict_mode => Off => Off session.use_trans_sid => 0 => 0re>以及php.ini配置的位置
Loaded Configuration File /etc/php.ini
接下来配置使用session主要项
在php.ini找到以下项并配置启用(去除前面;号,并配置相应的值)
session保存位置
;session.save_path = "/tmp"re>session过期时间
session.gc_probability = 1 session.gc_divisor = 1000 session.gc_maxlifetime = 1440re>三个属性得结合使用
回收概率:session.gc_probability/session.gc_divisor
即1/1000就是session 1000次才有一次被回收。只要你的访问量大了,那就能达到回收的效果。
如果你设置session.gc_divisor = 1,过期回收就很明显了
session.gc_maxlifetime单位为 秒,默认1440秒=24分钟