login.php
Verify the account password is not sent, send the code to set the session for everyone to see
Session_Start ();
$_session["userid"]= $rs [ID];
$_session["USERACC"]= $rs [Acc '];
$_session["username"]= $rs [Name];
$_session["usertype"]= "user";
Ob_start ();
Header ("location:index.php");
Ob_end_flush ()
index.php
if ($_session[' userid ']!= ') {
echo "Login Successful";
echo "Exit";
}else{
echo "Login Failed";
}
logout.php
The first form of a notation
Session_Start ();
$_session=array ();//Empty the $_session array
Setcookie (Session_name (), "", Time ()-1); Empty the cookie
Session_destroy (); Delete this session
The second type of notation
Session_Start ();
unset ($_session[' userid ');
unset ($_session[' USERACC ');
unset ($_session[' username ');
unset ($_session[' usertype ');
Session_destroy ();
And finally all executed
Ob_start ();
Header ("location:index.php");
Ob_end_flush ();
But I do not know why, after the execution of logout.php (two kinds of writing have tried) back to index.php or login success, the $_session inside the data are still there. But I interrupted logout.php jump in front of the $_session inside is no value. Please master guide what is the problem!
Reply to discussion (solution)
Back to index.php, is it through the browser back button?
That doesn't reload the page of course it won't change
Back to index.php, is it through the browser back button?
That doesn't reload the page of course it won't change
No, that's the redirect jump in the header that was used,
It's all right on my own machine, not on the server.
This machine is using an Apache server that is IIS
There must be something wrong with you!
Test code:
index.php
login.php
logout.php
There must be something wrong with you!
Test code:
index.php
login.php
!--? Phpsession_start (); $_session["userid"] = 1;ob_start (); Header ("Location: index.php "); Ob_end_flush ();
logout.php !--? Phpsession_start (); Session_destroy ();//Delete this session Ob_start ( ); Header ("location:index.php"); Ob_end_flush ();
now looks like session_destory (); This method is invalid in IIS
I $_session = Array (); The
is then session_destory ();
found that the previous $_session inside the data are back, so the consistent is the login status,
behind the session_destory ();
is removed
do not know what kind of error or impact this will occur.
want to save the moderator
Session_unset ()
Session_unset ()
The statement that empties the SESSION array uses the
unset ($_session[' userid '); this
Session_unset (); this
$_session = Array (); This
, whatever it is, One, as long as the back is written on the Session_destory ()
The data inside is all back again.