Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8812549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:37:52+00:00 2026-06-14T03:37:52+00:00

I create a file logout.php and calling it by <a href=’logout.php’>log out</a> but the

  • 0

I create a file logout.php and calling it by

 <a href='logout.php'>log out</a>

but the sessions are not destory or unset. Help me the logout.php file is given below

  <?php session_start();

  if(isset($_SESSION['user_id']) | isset($_SESSION['mem_id'])|                         
   isset($_SESSION['fname']) | isset($_SESSION['lname'])) {

   $_SESSION=array();
   unset($_SESSION['user_id']);
   unset($_SESSION['mem_id']);
   unset($_SESSION['fname']);

  if(isset($_COOKIE[session_name()]))  {

  setcookie(session_name(), '' , time()-3600);
 } 
   session_destroy();
    }
  header("location:index.php"); 
   ?> 

In my login file i genrate three session variable they are

   $_SESSION['user_id'])
   $_SESSION['mem_id'])
   $_SESSION['fname'])

Help me to destroy this session variable

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:37:53+00:00Added an answer on June 14, 2026 at 3:37 am

    You don’t do $_SESSION=array();, the variable already exists and is an array, you don’t declare as one again.

    You also need to use || for OR. a single pipe | is a bitwise operator and not what you want.

    ... isset($_SESSION['user_id']) || isset($_SESSION['mem_id']) ...
    

    One thing you can do to debug is have it echo something inside the if statement. If it does echo it to the screen, you know it go into that if statement. If it didn’t, you know it did not. Then you can begin to figure out if the conditions for the if statement are met or not to find what’s wrong.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's an idea. I'm trying to create file from PHP script. File may be
Possible Duplicate: PHP create a file without fopen I want to create a file
To be more clear, I do understand how to create a new php file
i want to create a hardlink from a file C:\xxx.log to C:\mklink\xxx.log . In
I have a logout file for my web application. I would like to create
I usually create modular websites, each part of the website being a .php file
I have a study logout.php file which works fantastically, the issue I am faced
I am new at PHP and even newer with PHP Sessions, but have been
I need to create file sharing and chatting system like Microsoft Groove under .NET
I create excel file with chart and it's working on my local machine with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.