PHP logout

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
merican
Forum Newbie
Posts: 22
Joined: Tue May 18, 2004 8:56 pm

PHP logout

Post 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
merican
Forum Newbie
Posts: 22
Joined: Tue May 18, 2004 8:56 pm

Post by merican »

Hi again,
I don't need to delete cookies or session, it just the page go to Logofg page.

Thank you
User avatar
maqmus
Forum Commoner
Posts: 30
Joined: Mon Mar 08, 2004 1:10 pm

Post 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>"; 
} 
?>
merican
Forum Newbie
Posts: 22
Joined: Tue May 18, 2004 8:56 pm

Post 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
User avatar
maqmus
Forum Commoner
Posts: 30
Joined: Mon Mar 08, 2004 1:10 pm

Post 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);
Post Reply