[請益] 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