最好将两个页面的代码全部贴出来。
比如说上面你根本没有对user_id赋值,第二个页面当然显示不了。
还有可能user_id跟其他变量名发生冲突等

解决方案 »

  1.   

    要修改php的系统文件,session的生命期在系统中默认为0
      

  2.   

    user_id是通过上一个页面的form传过来的,已经符了值的。
    程序就这么简单,可是就是不行啊!!!!
    我吐血!!!
    关注中!
      

  3.   

    错误可能在与这个user_id根本没有用form传过来
    更改php.ini
    register_global=on
    试一试先
    新版本都是off
      

  4.   

    register_globals本来就是on的,user_id也传过来了,因为临时文件里看得到数据的啊。
      

  5.   

    有可能客户端ie不支持cookie,你试一试其他的电脑或者将ie设置设为默认值
      

  6.   

    奇怪了?
    第二个页面中,try:
    session_start();
    echo $HTTP_SESSION_VARS[user_id];
      

  7.   

    第二个页面session_start();不要用,因为会自动删除原来的session,
    我的终极解决办法是直接分析session原文件!决不会出错!!!!
    有兴趣的朋友请联系!
      

  8.   

    第一个页面写成这样:
    session_start();
    $_SESSION["user_id"]++;第二个页面中:
    session_start();
    echo $_SESSION["user_id"];
      

  9.   

    注意$_SESSION在php4.1.0以後才引入最好把你的session相關的配置貼出來
      

  10.   

    to wasy : 顺便说说吧,$HTTP_*_VARS[]是什么时候引入的?
      

  11.   

    [Session]
    session.save_handler      = files   ; handler used to store/retrieve data
    ;;;; #### **** modified {
    session.save_path         = C:/KedingSoft/php4/tmp    ; argument passed to save_handler
    ;;;; #### **** }
                                        ; in the case of files, this is the
                                        ; path where data files are stored
    session.name              = PHPSESSID  
                                        ; name of the session
                                        ; is used as cookie name
    session.auto_start        = 1       ; initialize session on request startup
    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;;;; #### **** modified {
    session.use_cookies       = 0       ; whether to use cookies
    session.cookie_lifetime   = 99999999999999999       ; lifetime in seconds of cookie
                                        ; or if 0, until browser is restarted
    session.cookie_path       = /       ; the path the cookie is valid for
    session.cookie_domain     =         ; the domain the cookie is valid for
    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"
    ;;;; #### **** }
      

  12.   

    老兄,你的session沒有用到cookie呀
    將session.use_cookies       = 0
    改為1$HTTP_SESSION_VARS[]是在php4以後的
    其他以前php3就有
      

  13.   

    $_XXX這種形式的預定義變量都是php4.1才引入的
      

  14.   

    哈哈哈,一定要将 session_start(); 放在每页的最开始。
      

  15.   

    问题解决了,不过我都不知道怎么解决的。
    就是反复改那几个设置,不行了再改,一不小心,好了!我吐血!
    不过对session的问题还不是很清楚,大家可以继续讨论,都有分的。
    我觉得php的session做的好麻烦哦,想想asp、asp.net的session多么方便啊。
      

  16.   

    asp的session也有限制吧,只能用于当前目录和子目录吧???看你的配置,我想肯定是你没有用到客户端cookie的原因。
    session.use_cookies       = 1
      

  17.   

    asp的session也有限制吧,只能用于当前目录和子目录吧???看你的配置,我想肯定是你没有用到客户端cookie的原因。
    session.use_cookies       = 1
      

  18.   

    1 mkdir session_path=/tmp  //手动建立session_path
    2 session_start=on