php - Logout on website? -


i'm implementing login/logout system on simple website i've created. i've implemented logging in through sessions, read on here

how connect user login cookie in php?

the first answer described sessions pretty , think have hang of it. questions logging out. put statement session_destroy();? i'd put in logout link, simultaneously destroy session , send them homepage. let me share code link of login , logout (it's same on pages).

<a href= <?php   if(isset($_session['user_id']))      echo"index.php"; else      echo"login.php"; ?>> <?php  if(isset($_session['user_id']))     echo"logout";  else     echo"login"; ?> </a> 

so made if session active, you'll see "logout" link redirects homepage. else, youll see login link , directed login page. how make when see logout link destroys session? thanks.

an href attribute supposed wrapped in quotations.

    href="<?php echo $this_var; ?>" 

then problem, suggest inject variable in url upon redirection when logging out,like so.

<?     echo 'login.php?value=logout'; ?> 

and in login.php

<?php     if(isset($_get['logout']))     {           unset($_session['user_id']);        //use if want user_id session unset.     } ?> 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -