session_destroy();


Posted on 16th Feb 2014 07:03 pm by admin

new to php
I have a simple login and am trying to write a logout.
I set a $_SESSION var to 1 if they are logged in:

Did you know?Explore Trending and Topic pages for more stories like this.
if(isset($_POST['logname']))
{
$UserArr = chk_lgn($_POST['logname'],$_POST['passwd']);
$_SESSION['iden'] = $UserArr['UserId'];
$_SESSION['logname'] = $UserArr['logname'];
}

if($_SESSION['iden'] !=0)
{
$_SESSION['auth'] = 1;
header('location:../UserPage/index.php');
}

elseif($_SESSION['iden'] == 0)
{
$_SESSION['auth'] = 0;
if($_POST){echo "Try Again.";}
}

In a include file I have this function:

function log_out()
{
if($_GET[auth==0])
{
session_unset();
session_destroy();
}
}

At the top(of index) I call the function, fallowed this in the html:

<p><a href="../index.php?auth=0">LogOut</a></p>

When I click logout I am still able to navigate to member pages.
Shouldn't auth=0 in the url be stored in $_GET and be available for logout?
Thanks
No comments posted yet

Your Answer:

Login to answer
319 Like 48 Dislike
Previous forums Next forums
Other forums

How to show next and prev records
Hi all,

Sorry if this is simple, i'm very new to php, well, any programming language actually

BB_Code error
I'm having a problem with a custom built function and keep getting this error:


Warning: M

Need help making a blockquote and line items conditional
I have some code I bought a few years ago that allows my clients to update content on their site usi

How to write on database when a link is clicked?
Hi, I have a list of products in a gridview. When the link is clicked currently it takes to an ext

db entry based on primary key
My "topics" table contains 10 entires
*--------------*
topicid topic
------

Need a Timecode Class...
Not a Time Stamp, Time Code. Format is a bit different. HH:MM:SS:FF where FF is Frames. I dont re

Header is not working in IE
Hi ! header function is not working in IE but it works in FF, Safari, Chrome. any help please. :

Php - mysql store data and use it later?
Hi, i' making a login page at the moment, however my username + password is stored many different pl

Count
Getting the same count everytime

Code:
$visitquery = mysql_query("SELECT COUNT(*) FR

Time script, set to my time zone?
I am using this line to get the date and time

Code: $time = date(F." ".d.", &q

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash