Sessions issue

There are 3 pages :




  • On 1.php, the user enters data, they are transmitted to 2.php through hidden fields

  • On 2.php session_start()and put the values ​​in the session. Also, on the second one, you still need to enter your login and password, if the logs are already registered in the database, then the user is sent again to 2.php.

The problem is that if the user is transferred back to 2.php. then the session is deleted.

The second problem is that even if I don’t send it and without any check, and just ask to withdraw from the session, it outputs something, but also writes

Warning: session_start() [function.session-start]: Cannot send session
cache limiter – headers already sent (output started at
Y:\home\localhost\www\u\parent.php:2) in
Y:\home\localhost\www\u\parent.php on line 3

Answer 1, authority 100%

In order for the session not to be erased, you must either make an array of values ​​(if you need to have several of them), or check for the existence of one or another value before writing anything there.

—————————————————– ————————————————– ——————————-

header already sent gives out because session_start()needs to be written at the very beginning of any code (to be as precise as possible, before any information is displayed), you don’t have this.

An example just in case 🙂

// .....
// ....
//  :)

If it isn’t, perhaps session_start()is called multiple times.

Answer 2

headers already send by also pops up because of the encoding of the php file, utf-8 without BOM to help.

Answer 3

  1. Before “< ? p h p” in which session_start() is called, there should not be any
    byte, this should be at the very beginning of the file
  2. session_start() must be at the very beginning of every file.