求救!!!!關於session的怪問題...

edited 十月 2013 in PHP新手區
環境 php5.12 phpmyadmin 2.7 apache 2.0 Winxp

求救!!!!關於session的怪問題...
我搞了兩天了~~~XDXD


原先我的php.ini的參數session.auto_start=0
每次呼叫session_start()都出現
Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at XXX.php:1) in XXX.php on line 18

Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at XXX.php:1) in XXX.php on line 18

後來我在某論壇找到ㄧ個說法...

the problem is that your php file've saved as "UTF-8" type. you can
check this by viewing your file with some HEX file edit tool. and as
you'll see, before the first char of your php code file (maybe "<" of
"<?php") is another char - the filetype-char (2 bytes) of "UTF-8"
filetype. OMG! it'll be the HTML text printed before your code and kicks
the page's headers out.

to fix it, u need to copy all your php code and paste it into Notepad,
then, u save the file as "ANSI" filetype.

u'll fix the problem. but another have caused, it's u can't use other
languages (or fonts) base on "UTF-8" like Vietnamese, right? hehe, but i
know u can fix it easy.

意思就是說不能用UTF-8編碼~~~~XDXDXD
真是見鬼了的bug...!!!
後來我去試了...把session_start()這個呼叫單獨放在依個ANSI編碼的php檔案...然後其他utf-8的程式碼用include進來...如此可以解決...
但是這實在太麻煩了~~

所以我把
php.ini的參數session.auto_start=1
之後就不用呼叫session_start()...也沒有前面的問題了~~


但是...但是...

phpmyadmin開始出問題了...

1.我用http模式會出現以下錯誤...且沒有跳出要求輸入帳號的視窗

Warning: ini_set() [function.ini-set]: A session is active. You cannot change the session module's ini settings at this time. in C:\Program Files\Apache Group\Apache2\htdocs\phpMyAdmin\libraries\session.inc.php on line 46

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\phpMyAdmin\libraries\session.inc.php:46) in C:\Program Files\Apache Group\Apache2\htdocs\phpMyAdmin\libraries\auth\http.auth.lib.php on line 25

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\phpMyAdmin\libraries\session.inc.php:46) in C:\Program Files\Apache Group\Apache2\htdocs\phpMyAdmin\libraries\auth\http.auth.lib.php on line 26

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\phpMyAdmin\libraries\session.inc.php:46) in C:\Program Files\Apache Group\Apache2\htdocs\phpMyAdmin\libraries\auth\http.auth.lib.php on line 27

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\phpMyAdmin\libraries\session.inc.php:46) in C:\Program Files\Apache Group\Apache2\htdocs\phpMyAdmin\libraries\auth\http.auth.lib.php on line 30


2.我用cookie模式會出現以下錯誤..

Warning: ini_set() [function.ini-set]: A session is active. You cannot change the session module's ini settings at this time. in C:\Program Files\Apache Group\Apache2\htdocs\phpMyAdmin\libraries\session.inc.php on line 46

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\phpMyAdmin\libraries\session.inc.php:46) in C:\Program Files\Apache Group\Apache2\htdocs\phpMyAdmin\libraries\auth\cookie.auth.lib.php on line 110

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\phpMyAdmin\libraries\session.inc.php:46) in C:\Program Files\Apache Group\Apache2\htdocs\phpMyAdmin\libraries\select_theme.lib.php on line 104




有沒有人遇過類似情形呀?~~~

原始討論: http://twpug.net/x/modules/newbb/viewtopic.php?topic_id=1512

評論

Sign In or Register to comment.