Results 1 to 2 of 2

Thread: Read IPB Cookie with external script

  1. #1
    Join Date
    Dec 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Read IPB Cookie with external script

    Hi there, hoping someone can offer some help please

    i have an ipb forum and have an external script which i want to read and decode the ipb cookie, and query the database to check if they are banned/registered etc.


    i have tried to use the $_Cookie variable in a few ways, but it seems to come up empty.

    Code:
       $usercookie = $_Cookie['user'];
    
       require('ipb_login_settings.php');
    	
       $cookie = base64_decode(addslashes($usercookie));
       $cookie = explode("||", $usercookie);
    
       $username = $cookie['1'];
       $userid = $cookie['0'];
    i notice throughout the other scripts a global $usercookie; but my external script cannot seem to see it?

    Never dealt with this kind of thing before, i know the ipb cookie is base64 encoded, help appreciated.

    ipb_login.settings.php contain the cookie_path etc and sql logins.

    Edit - also like to say that the external script is on the same domain.

    Thanks
    Last edited by jasper33; 12-17-2007 at 09:50 PM. Reason: added a note

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    ipb is a bit complex to work with.

    First, I suggest just printing the $_COOKIE array.
    Run this:
    print_r($_COOKIE);

    See what comes out. that's what you have to work with.

    There should be, if I remember correctly, a username, a password hash, and a few things that won't like, like last activity and post time.

    That should just get you the username and if they are logged in. Session ID can be used against the database for this as well.


    As for querying the database, it involves using the ipb_sessions table, and checking if the info in the cookie matches.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •