PHP uses session Remember me

Tucao, novice to learn php, always problems ah ~!

I have been doing this login module, that bothers me two days of the session in the Great God help me solve.

Simply speak!

Has been written by the Internet to write ah, ah change change!

First code can write it! !

There checklogin.php this section:


// After a successful login,
session_start (); // initially the session
        $ _SESSION [ 'the Username'] = 'to true'; // Assignment must give ah! ! I just forget this one!
echo "<script> alert ( 'successful landing ...!'); location.href = 'index.php' ;; </ script>"; // is transferred after index.php
//header("Location:index.php");


Then index.php

Inside it corresponds to this paragraph:

? <PHP 
session_start (); // thing is to start the session
if (!! isset ($ _SESSION [ 'Username']) || ($ _ SESSION [ 'Username']) = 'true') // this is also very critical ah, to determine whether there is, and the value is correct, this is understandable, right? ?

I. . Anyway, is not logged in, then the implementation of IF
{
echo "You are not logged in, please log on <a href='login.php'> </a>!";   
Exit (); 
 } 
>?

After Failure to do so if, then it continues to execute the following code? ?

Well, so be it!

Published 33 original articles · won praise 12 · views 70000 +

Guess you like

Origin blog.csdn.net/gzh8579/article/details/22747745