PDA

View Full Version : Read IPB Cookie with external script



jasper33
12-17-2007, 09:49 PM
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.


$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

djr33
12-17-2007, 11:13 PM
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.