Home php Warning: Session_start () : Cannot Session Cache Limiter

Warning: Session_start () [Function.session-Start]: Cannot Session Cache Limiter

Author

Date

Category

In general, the problem is as follows:

Warning: Session_start () [Function.session-Start]: Cannot Session Cache Limiter – Headers Already Sent (Output Started AT Z: \ Home \ Localhost \ www \ login.php: 1) in z: \ Home \ Localhost \ www \ ses \ login.php on line 16

read the forums, they write that the problem is in encoding. I installed UTF-8 everywhere without BOM (in NotePad ++), but the problem remains:

Form.php

& lt; html & gt;
  & lt; Head & gt;
    & lt; Title & gt; login & lt; / title & gt;
  & lt; / Head & gt;
  & lt; Body & gt;
    & lt; Form Method = "POST" ACTION = "LOGIN.PHP" & gt;
    & lt; p & gt; Username: & lt; Input Type = "text" name = "username" / & gt; & lt; / p & gt;
    & lt; p & gt; Password: & lt; Input Type = "text" name = "password" / & gt; & lt; / p & gt;
    & lt; p & gt; & lt; input type = "submit" Value = "Let Me In" / & gt; & lt; / p & gt;
    & lt; / form & gt;
  & lt; / body & gt;
& lt; / html & gt;

login.php

& lt;? php
// Check the correctness of UserName and Password
If ($ _POST ["UserName"] == "PHP" & amp; & amp; $ _post ["Password"] == "PHP") {
  // If you are correct, set the session value in YES
  session_start ();
  $ _Session ["Login"] = "Yes";
  Echo "& lt; h1 & gt; You have entered correctly & lt; / h1 & gt;";
  echo "& lt; p & gt; & lt; a href = 'document.php' & gt; reference to a protected file & lt; / a & gt; & lt; p / & gt;";
} else {
  // if incorrect, set the session in no
  session_start ();
  $ _Session ["Login"] = "no";
  Echo "& lt; h1 & gt; You have entered incorrect & lt; / h1 & gt;";
  echo "& lt; p & gt; & lt; a href = 'document.php' & gt; reference to a protected file & lt; / a & gt; & lt; p / & gt;";
}

Answer 1, Authority 100%

Read Forums. Forum they write that the problem is in the encoding.

nope

Headers, incl. The session should be output to the body of the page. Page body begins at least here

& lt; html & gt; & lt; Head & gt; & lt; Title & gt; login & lt; / title & gt;

And heders are sent here:

session_start ();

Answer 2, Authority 100%

If the sessions are needed on each page, then open PHP.ini and find there session.auto_start .

turn it on.

session.auto_start = 1


Answer 3, Authority 100%

In the page page login.php Remove all spaces in front of & lt;? PHP .

Update

So all the same gaps were. The problem, as you expressed, not in the session – the session cannot be launched, because there is some Output in line 1 of the login.php file. It is easier to do the following now: Create a file in a laptop, copy the code there, save as login.php and rewrite. If you are extremely extreme, then “consider” your original login.php in the editor that displays the so-called. non-printable characters . Or browse it in Hex-Viewer – it will help see what is standing in front of the & LT; symbol. I am sure that there will be something.


Answer 4

1.

// if correctly set
Session value in YES
session_start ();

If the session is needed in the file, then it must be announced at the very beginning of the file and only then the rest of the code.
& lt;? php session_start (); ? & gt;
& lt; html & gt;
& lt; Head & gt;
…….

2.
To stop session Session_Stop ();


Answer 5

Well, yes! First session_start () and then everything else. You first go data (so you check the array of the post) then it is not empty for you, the data through the form is sent. And then you already start the session. Hence the error. First, the start session, and then check the array $ _post

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions