[请益] php.ini的Session设定启用

楼主: pavlov (海风)   2016-02-13 04:56:17
//以下是phpinfo()输出结果
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 On On
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 /share/Web/php/session/ /share/Web/php/session/
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 100 100
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.hash_bits_per_character 4 4
session.hash_function 0 0
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /share/HDA_DATA/.php_session /share/HDA_DATA/.php_session
session.serialize_handler php php
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 1 1
//以下是php.ini
[Session]
session.save_handler = files
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 1
session.cookie_lifetime = 0
session.cookie_path = /share/Web/php/session/
session.cookie_domain =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 100
session.gc_maxlifetime = 1440
session.bug_compat_42 = 1
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 1
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="
session.save_path = /share/HDA_DATA/.php_session
//以下是 session01.php
<?php session_start(); ?>
<html>
<head>
<meta http-equiv="Content Type" content="text/html; charset=UTF-8">
<title>session01
</title>
<style>
</style>
</head>
<body>
<?php
$_SESSION['IDX1']=10;
$_SESSION['IDX2']=20;
echo "<hr>";
echo '<a href="session02.php">Go to Page-Session02</a><hr>';
?>
</body>
</html>
//以下是 session02.php
<?php session_start(); ?>
<html>
<head>
<meta http-equiv="Content Type" content="text/html; charset=UTF-8">
<title>session02
</title>
<style>
</style>
</head>
<body>
<?php
echo "IDX1 is:".$_SESSION["IDX2"]."</br>";
echo "IDX2 is:".$_SESSION["IDX2"]."</br>";
echo "<hr>";
echo '<a href="session01.php">Go to Page-Session01</a><hr>';
?>
</body>
</html>
//先在浏览器开session01.php,点击Go to Page-Session02显示以下:
<html>
<head>
<meta http-equiv="Content Type" content="text/html; charset=UTF-8">
<title>session02
</title>
<style>
</style>
</head>
<body>
IDX1 is:</br>
IDX2 is:</br>
<hr><a href="s1.php">Go to Page-Session01</a><hr>
</body>
</html>
//问题:要如何修改php.ini才能使Session正常可用?
//才有办法在最后使之出现: IDX1 is:10 和 IDX2 is:20
//环境补充说明:
// QNAP QTS 4.2.1
// PHP 5.5.29
// Server API:Apache 2.0 Handler
// Apache API Version:20051115
作者: JustGame (JustGame)   2016-02-13 22:35:00
猜测是 /share/HDA_DATA/.php_session 这个目录不存在或权限问题。可以试着用 http://goo.gl/s7bqO3 的方法把错误印出来看这样就知道问题出在哪里

Links booklink

Contact Us: admin [ a t ] ucptt.com