session_start()之前不能有输出。If you want your script to work regardless of register_globals, you need to instead use the $_SESSION array as $_SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled.
如果你的浏览器版本高就没这个问题了,IE6.0好像会忽略header重发的情况 还有写入session的语句不要这样写了,关于session的新写法请查看相关资料 老的教科书过时了 下面是英文的一段描述,自己看看,如果看不懂英文就不要再写程序了,改行吧If you want your script to work regardless of register_globals, you need to instead use the $_SESSION array as $_SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled. register_globals: important note: Since PHP 4.2.0, the default value for the PHP directive register_globals is off. The PHP community encourages all to not rely on this directive but instead use other means, such as the superglobals. Caution: This registers a global variable. If you want to register a session variable from within a function, you need to make sure to make it global using the global keyword or the $GLOBALS[] array, or use the special session arrays as noted below. Caution: If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered(), and session_unregister().
session_start();//这个最好要用在你所有使用session的PHP网页的最顶部,
session_register('aaa');phpinfo();
?>
还有写入session的语句不要这样写了,关于session的新写法请查看相关资料
老的教科书过时了
下面是英文的一段描述,自己看看,如果看不懂英文就不要再写程序了,改行吧If you want your script to work regardless of register_globals, you need to instead use the $_SESSION array as $_SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled. register_globals: important note:
Since PHP 4.2.0, the default value for the PHP directive register_globals is off. The PHP community encourages all to not rely on this directive but instead use other means, such as the superglobals. Caution:
This registers a global variable. If you want to register a session variable from within a function, you need to make sure to make it global using the global keyword or the $GLOBALS[] array, or use the special session arrays as noted below. Caution:
If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered(), and session_unregister().
2、确保被session_register的变量是全局变量
3、session_register只适用于php4.0.x