...

View Full Version : destroy cookie in logout



avizhome
03-26-2010, 08:50 AM
Hi,
I have a small login from with the basic username & password field. The values are then passed to a php page which redirects to the main login page, if the login was successful then a cookies value is set. Now i want to have a logout that will destroy my cookie once clicked, please find my code below:



if (isset($_COOKIE["user"])){

echo "<tr>";
echo "<td>Logged in As:</td>";

echo "</tr>";
echo "<tr>";
echo "<td>".$_SESSION['username'] . ";</td>";
echo "</tr>";
//Here i want a logout button that when clicked should destroy my cookie.
echo "</tr>

MattF
03-26-2010, 10:05 AM
Set the cookie with a date a few weeks or months in the past to ditch it.

avizhome
03-26-2010, 10:09 AM
Thanks Matt, but how can I trigger the destroy session by a button?

abduraooft
03-26-2010, 12:48 PM
Add the required coded to unset session and change cookie's time in a page, say logout.php and then add a link to this page like

<a href="logout.php">Logout</a>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum