php session problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vijay_587
Forum Newbie
Posts: 1
Joined: Sat Nov 27, 2010 3:01 pm

php session problem

Post by vijay_587 »

hello,
I am beginner in php.....I got a problem in following script
<?php
session_start();
$logout = $_POST['logout'];
if(isset($logout)){
unset($_SESSION['uname']);
unset($_SESSION['password']);
session_destroy();
header('location:registrationform.php');
}
?>
according to the above script when i click on logout button my page go to my registrationform page but when i click back button in my browser it goes back to above script means to the logout page....what is the reason for that......i also want to know how to setup my session from login till logout.
thanks in advance.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: php session problem

Post by Christopher »

You want ot check if the actual $_POST variable is set:

Code: Select all

if(isset($_POST['logout'])){
(#10850)
Post Reply