Page 1 of 1

PHP logout

Posted: Tue May 25, 2004 10:26 pm
by merican
Hi all,
I need some help here. I have a page with control panel at side template and their function at main template.There is a Logoff at the side template.What I want is, when I cklick Logoff, the page will link to Login page. But the problem i have is when i click the Logoff, the side template is there and only main template show the Login page.Below is my code for Logoff text:-

Code: Select all

if (preg_match("/@6/",$this->user_level)) {
 options .="<tr>
 <td bgcolor="#008080"><font size="2">
 <a href="admin.php">Logout</a></font></td>
 </tr>";
&#125;
Can anyone help me with this.I need when i click the logoff, all page will go to Login page.
Thank you in advance.

Regards,
Alfy

Posted: Wed May 26, 2004 2:53 am
by merican
Hi again,
I don't need to delete cookies or session, it just the page go to Logofg page.

Thank you

Posted: Wed May 26, 2004 2:54 am
by maqmus
Do you mean this?

Code: Select all

<?php
if (preg_match("/@6/",$this->user_level)) { 
options .="<tr> 
<td bgcolor="#008080"><font size="2"> 
<a href="admin.php" target="_top">Logout</a></font></td> 
</tr>"; 
} 
?>

Posted: Wed May 26, 2004 2:59 am
by merican
hi maqmus,
That easy ha...hahahha..I solve it...Thanks mate...but that code didn"t actually delete the cookies and session right? How to do that?

Thank you in advance.
regards,
alfy

Posted: Wed May 26, 2004 3:19 am
by maqmus
You'll need to set the function in admin.php or in the actual script and the add header("location:admin.php");
However you want to use session_destroy() or session_unset().

For the cookies I like to unset them assigning an empty value: eg
setcookie("username", "", time() - 2000);