TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 02-20-2008, 03:11 AM   #1 (permalink)
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 136
Thanks: 4
Gareth is on a distinguished road
Confused $_session - Ugh!

Hey.

Okay, its late so I thought I'd explain this in pictures :P











Here is logout.php:

PHP Code:
<?php

require_once("conf_global.php");

  
$_SESSION['is_logged_in'] = 0;
  
$_SESSION['username'] = "Guest";

    
session_destroy();

    echo 
$_SESSION['is_logged_in'] ;
    echo 
$_SESSION['username'];
?>
and the part of login.php specific to setting Session Vars:

PHP Code:
if($login){
                            
                            
$_SESSION['is_logged_in'] = 1;
                            
$_SESSION['username'] = "$_POST[user]";
                            
                            echo 
'<h1>Thank you for logging in</h1>';                
                            echo 
'<div class="mainContent">';
                            echo 
'Thank you, <strong class="orange">'$username ' </strong>you are now logged in. You are being redirected to your user panel.';
                            echo 
'<meta http-equiv="refresh" content="3;url=usercp.php">';
                            echo 
'</div>';
                        } 
And the part in usercp.php

PHP Code:
<strong>Logged In As: </strong> <span class="orange"><?php echo $_SESSION['username']; ?></span>
I dont see what I'm doing wrong: do you?

Thanks a bunch :)

Gareth
Gareth is offline  
Reply With Quote
Old 02-20-2008, 03:12 AM   #2 (permalink)
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 136
Thanks: 4
Gareth is on a distinguished road
Default

I'm an idiot; I was destroying the session! Its sorted now :)
Thanks guys for the help (damn that was quick!)
Gareth is offline  
Reply With Quote
Old 02-20-2008, 08:08 AM   #3 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Why were you destroying it in the first place? What was the purpose to add it? Besides a log out system..
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 02-20-2008, 09:26 AM   #4 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default

PHP Code:
<?php

require_once("conf_global.php");

$_SESSION['is_logged_in'] = 0;
$_SESSION['username'] = "Guest";

echo 
$_SESSION['is_logged_in'] ;
echo 
$_SESSION['username'];

session_destroy();

?>
That should be correct.
__________________
Necessity is the mother of invention.

My blog
Haris is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 06:17 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design