记住用户名密码
1、找到php.ini配置文件,找到session.save_path,修改如下: 其中2表示session存储的目录深度,也就是分目录,避免一个目录下文件太多,造成IO负担。 session.save_path = "2;D:\xxx\php54\session" 2、如上设置后,重启apache后,在php文件session_start()后会报错。 Warning: session_start(): open(D:\xxx\php54\session\b\9\sess_b9h5uo3bra9j28f4p4rim8mg02, O_RDWR) failed: No such file or directory (2) in D:\wwwroot\test\index.php on line 2 Warning: Unknown: open(D:\xxx\php54\session\b\9\sess_b9h5uo3bra9j28f4p4rim8mg02, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (2;D:\xxx\php54\session) in Unknown on line 0 3、原来是session下的\b\9目录需要手动创建,所以写了一个函数。 <?php function createSessionDir($sessionPath = '') { if(empty($sessionPath)) { return false; } $dirNameArr = array_merge(range(0, 9), range('a', 'z')); $sessionPath = rtrim($sessionPath, '\/') . DIRECTORY_SEPARATOR; foreach ($dirNameArr as $dirName) { $dirPath = $sessionPath . $dirName . DIRECTORY_SEPARATOR; foreach ($dirNameArr as $subDirName) { @mkdir($dirPath . $subDirName, 0777, true); } } } createSessionDir('D:\xxx\php54\session');
目前有 0 条留言 其中:访客:0 条, 博主:0 条