Why is PHP session destroy not working

0 votes

Why is session_destroy() not working?

Is there any other way to destroy the session in PHP?

if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) 
{   
    session_destroy();   
    session_unset();     
}

Can someone please help me on this?

Jun 12, 2022 in PHP by narikkadan
• 63,600 points
1,518 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
When you use the session_destroy(), it will be destroyed behind the scene. So the values in  $_SESSION  will not be affected. But it will be empty in future requests or you can manually clear $_SESSION if you so desire ($_SESSION = [];).

I hope this helps you.
answered Jun 12, 2022 by Kithuzzz
• 38,000 points

edited Mar 5

Related Questions In PHP

0 votes
0 answers

ErrorDocument 404 /404.php is not working in .htaccess file in PHP

This is the Content of my .htaccess file is: ErrorDocument ...READ MORE

Jun 21, 2022 in PHP by narikkadan
• 63,600 points
940 views
0 votes
0 answers

Why command "php artisan serve" not working?

My Laravel on this path: C:\Users\Mad\Work\trunk\product\backend\v1.2.1\laravel But it is ...READ MORE

Jul 26, 2022 in PHP by Kithuzzz
• 38,000 points
1,595 views
0 votes
1 answer

How to check if php session is already started or not?

Hello kartik, Use session_id(), it returns an empty string ...READ MORE

answered Apr 1, 2020 in PHP by Niroj
• 82,840 points
5,990 views
0 votes
0 answers

PHP is not recognized as an internal or external command in command prompt

I am getting this error when I ...READ MORE

May 7, 2022 in PHP by narikkadan
• 63,600 points
2,277 views
0 votes
0 answers
0 votes
0 answers

PHP - If variable is not empty, echo some html code

I want to display some HTML code ...READ MORE

Jun 4, 2022 in PHP by Kichu
• 19,040 points
1,007 views
0 votes
1 answer

"Cannot send session cache limiter - headers already sent"

The line "Headers already sent" means that ...READ MORE

answered Feb 18, 2022 in Others by Aditya
• 7,680 points
7,404 views
0 votes
0 answers

PHP Unset Session Variable

I am working on creating a product ...READ MORE

Jun 9, 2022 in PHP by Kichu
• 19,040 points
1,141 views
0 votes
0 answers

What is the difference between Sessions and Cookies in PHP?

What is the distinction between Sessions and Cookies ...READ MORE

Jun 13, 2022 in PHP by narikkadan
• 63,600 points
475 views
0 votes
0 answers

Using sessions & session variables in a PHP Login Script

I have created a login and register ...READ MORE

Jun 17, 2022 in PHP by narikkadan
• 63,600 points
728 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP