PHP Session lost after redirecting -
I really can not solve the problem that troubles me / only partly can solve it. Good juicy for you professionals.
I have a basic login system installed. Like this:
Log in. Php:
- Line 1:
session_start ();
- If checked
($ _SESSION ['logged_in'] == true) header ("location: /controls.php)"; , if they have already entered their details.
- If they have not entered if they are valid:
$ _ session ['log-in'] = true;
- After checking the database credentials and the session is set to True, redirect using the
header ("location: /controls.php); < Remember, the session is now set.
Controls.php
- Line 1:
session_start ();
- Line 2:
if ($ _ session ['login'] = true) {header ("location: /index.php");}
Immediately I am taken to index.php in Chrome and Firefox.
In addition, I have
accounttools.php , where the session's come Once I try to reach
accounttools.php , the session is destroyed / unset and the load to
accounttools.php Any attempt to redirect the header to my /index.php page, then only in Firefox and Chrome.
I have to add something in. If I return to
login.php I go and login again, so everything is fine and the session is set properly Is Raozer-based Bug? PHP is implemented before any data is sent to the browser, so how can these browsers work differently if PHP has already been executed for some time by the user?
Login File:
// login.php
File controls:
// controls.php // This page redirects to index.php immediately $ _ session / <>, then
$ _ The session is not deleted
is a part of the header () redirect which is generating
$ _ session for unsetting / deletion in Google and Mozilla .
I was googling like crazy and apparently this is a common problem between PHP coders, anyone should know what it is? Successful Login: This is a JavaScript redirect, so it will only happen when all PPPs are executed and The results will be sent to the browser. This means that codes are executed even after your redirects.
I suggest not to output anything to the browser and use it by the end:
header ("location: / ..."); Go out();
Everywhere you want to redirect, so that you are certain that there is nothing in your session after the redirect code.
Headers have already been sent Problems, I also recommend getting rid of stuff:
? & Gt; & Lt ;? Like the first lines of Php
login.php
- Line 2:
- If checked
Comments
Post a Comment