When using php session today, the following prompt is displayed:
Warning: session_start () [function. session-start]: Cannot send session cache limiter-headers already sent (output started ..
Because there are other html code before the session_start (); statement
Solution:
Modify session. auto_start = 0 in php. ini to session. auto_start = 1.
Set variables
The code is as follows: |
Copy code |
Session_register ("user "); $ _ SESSION ["user"] = $ name; Obtain Session_start (); Echo $ _ SESSION ["user"]; |
If the problem persists, check whether the encoding problem is correct.
1. Convert the error file to UTF-8 code without BOM format (I usually use Notepad ++ to convert)
2. Enable slowdown with ob_start? Write the output information in the partition to slow down? To avoid the headers output prior to session_start ().
The code is as follows: |
Copy code |
<? Php Ob_start () Echo "test" Session_start () Ob_end_flush () ?> |
Some friends added: session. save_path = "C:/phpsession" [the path at the backend must be set by yourself and be sure to exist. In fact, this is incorrect. We have configured it when configuring php, do not modify the session if other programs have no problems. the save_path path is saved.