Menu

#8 how to check the cookie?

open
nobody
None
5
2001-10-17
2001-10-17
Anonymous
No

I've got authlib up-and-running perfectly, with my own
fields and a couple of other additions; however, how
do I then check for the existence of the cookie on
other pages I want to have access restricted to?

Discussion

  • Jeff April

    Jeff April - 2001-12-08

    Logged In: YES
    user_id=392739

    To do this, I have found that you need to do the following.

    1.) modify backend.php and change the call to setcookie in
    the login function to include the path to be "/" if you
    want the cookie to be available outside of the authlib
    directory structure.
    setcookie("authlib", "$username:$hash:$id", time()
    +3600, "/")

    2.) then to check the cookie, make sure that your page is a
    php page, and include the following code:

    <?
    require ("./authlib/backend.php");
    $login_check = $authlib->is_logged();

    if (!$login_check)
    {
    //User is not logged in.
    }
    else{
    //User is logged in.
    }
    ?>

    I think that should do it for you.

     
  • Nobody/Anonymous

    Logged In: NO

    sory bat this change in my script not work
    why???

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.