Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 7th, 2008, 02:37 AM
Authorized User
 
Join Date: Jul 2008
Posts: 18
Thanks: 0
Thanked 2 Times in 2 Posts
Default Warning on session_destroy()

Can anyone help me?

I have an login page and i am authenticating and setting my session variable, thats works fine. when i click the logout i got the following error

"trying to delete uninitialized session on line number 3"

here is my logout code logout.php [ i am using php4.2 ]

session_start();
session_unset();
session_destroy();
header('Location:./login.php');


Thanx in advance

 
Old December 17th, 2008, 08:21 PM
Registered User
 
Join Date: Dec 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default safe session_destroy

You could try this:

PHP Code:
<?php
session_start
();

// Your Code

session_unset();

if (
session_id() !== "")
{
    
session_destroy();
    
// Session is destroyed!
} else {
    
// There's no session to destroy!
}

header('Location: http://www.example.com');
?>
 
Old February 10th, 2009, 06:17 AM
Authorized User
 
Join Date: Feb 2009
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Default

hi

session_unset — Free all session variables

So u already made free all session variables

And

session_unregister() just Unregister a global variable from the current session





Similar Threads
Thread Thread Starter Forum Replies Last Post
meaning of a warning mastrgamr C++ Programming 7 December 22nd, 2006 08:16 AM
Security Warning ggiibboo Access 0 January 3rd, 2006 03:11 AM
Warning: session_start(): khile Beginning PHP 3 August 16th, 2005 04:09 AM
Warning: mysql_num_rows()... mgway Beginning PHP 3 July 11th, 2005 07:17 PM
session_destroy on exit?? harmen_wessels PHP How-To 2 July 5th, 2003 09:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.