PHP | How to destroy session?

PHP Session
On +Wizpert, Someone asked me that how to destroy session?
Session is used for specific purpose. like
  • Login user
  • Review creation
  • Forms Creation
  • Check Out system
  • And more
In this code you will learn, How to destroy session on logout click?


 <?php  
 $_SESSION = array(); // Oh Sorry here you need to null all sessions  
 setcookie(session_name(), '', time()-60); // here you will set cookies time back to age. like time()-60 mean . 1 minute before now.  
 session_destroy(); // here you will delete session  
 header("Location: login.php"); // here you will be reallocated to login.php page.  
 exit; // page code will be exit.  
 ?>  

I hope this can help you.
Share this article :

Post a Comment

Give your reviews about this blog. Leave your comments. What do you think about this post?

Comments Guidelines:

1) I love to read comments, but please avoid spam.

2) Like this blog, share your insights, and spread the word.

3) You can use basic HTML/xHTML tags.

4) All comments are DoFollow—please use the section professionally.

5) Kindly mention your name or brand below your comment.

6) Constructive suggestions for improvement are always welcome.

7) Do not forget to explore our main agency platform at pingbooster.site.

Thanks for visiting Samee Articles.

========================================

Explore custom digital solutions and WordPress plugins at PingBooster Plugins.

Best Regards,

Samee U. Feroz

 
Copyright © 2013-2016. Samee Articles - All Rights Reserved
Proudly powered by Blogger