The PHP Group PHP
Problem for The PHP Group PHP

Logout script with session management in php5




By don393 on Dec 30, 2008

" "
i failed to script a logout web page in php with session management.my script doesn`t get any affect by logging out when the BACK button is pressed.can u help me

Clarification Request

Posted by fetusbata on Jan 09, 2009

hi, can you give me the code that you made?
I'll suggest to use cookies because cookies are suited for logging out implementation. As what i have read, session is use for passing the data to another page.

Best Solution

posted on Mar 17, 2009
Helpful)

djroot2

Rank: Master 
Rating: 92%, 13 votes
just create a logout.php script with the following

<?php
session_start();
session_destroy();

header("Location: index.php");
?>

Have your logout button/link/whatever just open that page which connects to the session with session_start. Session destroy does exactly what it sounds like... it unsets all session data and tells the server to end the session. The header request then just re-directs the user to whatever page you want after (just change out index.php)

Comments:

Mar 17, 2009

- I should have added the following between the session_start() and session_destroy() as session_destroy doesn't actually unset the variables and won't delete any cookies set.

$_SESSION = array();

if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}
Was this helpful?
Yes
No
1 person thought this was helpful

Solution #2

posted on Feb 06, 2009
Somewhat Helpful)

rou fix

Rank: Apprentice 
Rating: 75%, 1 votes
if it doesnt take effect its probably not actualy exicuting your logout script right.

the main part would be that it does this... (eg. level session)
unset($_SESSION['level']);

as soon as thats happend the session should be gone

oo and its worth double looking out for having ..
session_start();
.. in there,
little line im always forgetting yet its so important


Was this helpful?
Yes
No

Popular Solutions for The PHP Group PHP


Questions and Unsolved Problems for The PHP Group PHP


Do you recommend The PHP Group PHP?
Answer

Answer
I ruined ccsearch.php can I get a new one ?

Answer
I want to execute java command for a software which is stored on my web server with the help of... (More)

Answer
subject avaluation system php w/ mysql codes how to evaluate subject using php w/ mysql

Answer
Hi there, I am using PHP5, where i need to mail with attachement. exact thing is, am getting the... (More)


Didn't find what you were looking for?

Describe your problem:

Select a Category:







Ask our Experts

 

Solve Your Problem Now!
Chat Live with an Expert
Chat Now
Browse popular Problems
More Common Problems
Most Common Problems for:
For The PHP Group PHP:

Top Programming Tool Experts

Rank: Guru Guru  

Solutions: 1464
Member Since: July 2009

Experience: I have owned a computer networking sales and service company.

Ask Me
Find more Programming Tool Experts

Top Computer & Laptop Repair

(513) 874-3306
We fix and repair laptop motherboard no video, no...
LaptopOnCall Inc.

(877) 934-6198
Send your laptop to us and we will diagnose the...
A+ Rated Oceanside Computer Sales & Service, LLC


       
Solve Your Problem Now!
Chat Live with an Expert
Chat Now

X
Continue
When the original poster rates a solution that was given to his own problem, that rating is locked!
X

Are you sure the solution content is Inappropriate?
   
Tech buddies can communicate directly to answer questions. Become a Tech Buddy and have direct access to your favorite expert for FREE!
Insert Link
Insert Image
Insert You-Tube clip
Insert List
Insert List
Spell Check

What is this?



Select