配置指南:
http://php.net/manual/zh/refs.basic.session.php
http://php.net/manual/zh/session.configuration.php
使用命令:
PHP -i
找到打印输出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 => 0
以及PHP.ini配置的位置
Loaded Configuration File /etc/PHP.ini
接下来配置使用session主要项
在PHP.ini找到以下项并配置启用(去除前面;号,并配置相应的值)
session保存位置
;session.save_path = "/tmp"
session过期时间
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
三个属性得结合使用
回收概率:session.gc_probability/session.gc_divisor
即1/1000就是session 1000次才有一次被回收。
只要你的访问量大了,那就能达到回收的效果。
如果你设置session.gc_divisor = 1,过期回收就很明显了
session.gc_maxlifetime单位为 秒,默认1440秒=24分钟
原文链接:https://www.f2er.com/centos/375096.html