怎样判断session开了没有? 我的php.ini 文件是这样的:[Session] session.save_handler = files ; handler used to store/retrieve data session.save_path = c:\temp ; argument passed to save_handler ; in the case of files, this is the ; path where data files are stored session.use_cookies = 1 ; whether to use cookies session.name = PHPSESSID ; name of the session ; is used as cookie name session.auto_start = 1 ; initialize session on request startup session.cookie_lifetime = 0 ; lifetime in seconds of cookie ; or if 0, until browser is restarted session.cookie_path = c:\temp ; the path the cookie is valid for session.cookie_domain = ; the domain the cookie is valid for session.serialize_handler = php ; handler used to serialize data ; php is the standard serializer of PHP session.gc_probability = 1 ; percentual probability that the ; 'garbage collection' process is started ; on every session initialization session.gc_maxlifetime = 1440 ; after this number of seconds, stored ; data will be seen as 'garbage' and ; cleaned up by the gc process session.referer_check = ; check HTTP Referer to invalidate ; externally stored URLs containing ids session.entropy_length = 0 ; how many bytes to read from the file session.entropy_file = ; specified here to create the session id ; session.entropy_length = 16 ; session.entropy_file = /dev/urandom session.cache_limiter = nocache ; set to {nocache,private,public} to ; determine HTTP caching aspects session.cache_expire = 180 ; document expires after n minutes session.use_trans_sid = 1 ; use transient sid support if enabled ; by compiling with --enable-trans-sid url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
web服务器软件是什么 php的版本号 有的版本没这种问题,有的要传SID。
下载php3win的phptriad.exe. (mysql+php4+Apache ) Apache 1.3.14 MySQL 3.23.32 PHP Version 4.0.5
index.php代码: <? session_start(); echo $HTTP_SESSION_VARS[username]; ?>try it now!
login.php代码
<?
session_start();
session_register("username");
$username="001";
header ("Location:12.php"."?" . SID);
?>
index.php代码:
<?
session_start();
echo SID;
?>
可以得到 PHPSESSID=ac2c7aa1606d93f02dc4a7c244af7312,
那么怎样通过SID得到$username呢?
我的php.ini 文件是这样的:[Session]
session.save_handler = files ; handler used to store/retrieve data
session.save_path = c:\temp ; argument passed to save_handler
; in the case of files, this is the
; path where data files are stored
session.use_cookies = 1 ; whether to use cookies
session.name = PHPSESSID
; name of the session
; is used as cookie name
session.auto_start = 1 ; initialize session on request startup
session.cookie_lifetime = 0 ; lifetime in seconds of cookie
; or if 0, until browser is restarted
session.cookie_path = c:\temp ; the path the cookie is valid for
session.cookie_domain = ; the domain the cookie is valid for
session.serialize_handler = php ; handler used to serialize data
; php is the standard serializer of PHP
session.gc_probability = 1 ; percentual probability that the
; 'garbage collection' process is started
; on every session initialization
session.gc_maxlifetime = 1440 ; after this number of seconds, stored
; data will be seen as 'garbage' and
; cleaned up by the gc process
session.referer_check = ; check HTTP Referer to invalidate
; externally stored URLs containing ids
session.entropy_length = 0 ; how many bytes to read from the file
session.entropy_file = ; specified here to create the session id
; session.entropy_length = 16
; session.entropy_file = /dev/urandom
session.cache_limiter = nocache ; set to {nocache,private,public} to
; determine HTTP caching aspects
session.cache_expire = 180 ; document expires after n minutes
session.use_trans_sid = 1 ; use transient sid support if enabled
; by compiling with --enable-trans-sid
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
php的版本号
有的版本没这种问题,有的要传SID。
Apache 1.3.14
MySQL 3.23.32
PHP Version 4.0.5
<?
session_start();
echo $HTTP_SESSION_VARS[username];
?>try it now!
我想过各种方法,在论坛上也咨询了许多意见,运行都不显示
我观察到,每次运行,在c:/temp文件夹里产生3个文件分别是:
1 !username|!haslogin|
2 username|s:3:"001";
3
第三个文件是空的
什么原因,你们从能得出什么结论?
真是奇怪。
有人说是系统的问题 (Windows 2000 profesional)
但是用cookie没有问题。
这个问题困扰我快一周了,csdn服务器总忙,经常进不来,所以很久没到这里了。请各位帮帮忙,拜托了。谢谢!