SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist kooshin.com's Avatar
    Join Date
    Dec 2003
    Location
    http://kooshin.com
    Posts
    505
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Loggin out of the members area

    I have made a small members area using the tutorials found on some site. Then I have the following code for logging out of the members area

    PHP Code:

    <?
    session_start
    ();
    echo 
    "<center><font color=red><strong>You are now logged out!</strong></font></center><br />";include 'loggin.htm';

    ?>
    but when the logout link is clicked it loads that text but the person is still logged in and can access pages by using direct urls like going to the members special page. So I need your help and post the right code if you can . I appreciate it.


    thanks,

  2. #2
    SitePoint Zealot Tjobbe's Avatar
    Join Date
    Sep 2004
    Location
    UK
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this:

    save it as logout.php

    PHP Code:
    <? session_start() ?>
    <HTML>
    <HEAD>
     <TITLE>Logout</TITLE>
    </HEAD>

    <BODY>
     <H2>Logout</H2>
     <?
        
    // if the user is logged in, log them out
        
    if ($logged_in_user) {
            
    session_unregister("logged_in_user");
            echo 
    "You are now logged out.";

        
    // if the user isnt logged in, let them know that
        
    } else {
            echo 
    "You haven't logged in yet.";
        }
     
    ?>
     <BR>
     <BR>
     <A HREF="login.php">Click here to log in.</A>
     <BR>
     <BR>
     <A HREF="register.php">Click here to register as a new user.</A>
    </BODY>
    </HTML>

  3. #3
    Obsessive designer Infizi's Avatar
    Join Date
    May 2004
    Location
    North Pole
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    look at the php.net site for information on using session_unset() and session_destroy() to end sessions


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •