PDA

View Full Version : username stored in vB cookie


siLk
01-22-2004, 06:59 AM
i would like to see a small hack that stores the username in the cookie along with the userid.

I have comments for multiple content areas on my website right now, and would like to force them to register an account on the forums before they can post, and then have that username automatically show up.

thanks :)

Edit, figured it out myself, just adding 2 lines to login.php so not sure if it is really a hack or just a small mod

if anyone is interested, i can attach the lines here?

Kentaurus
01-22-2004, 05:42 PM
i would like to see a small hack that stores the username in the cookie along with the userid.

I have comments for multiple content areas on my website right now, and would like to force them to register an account on the forums before they can post, and then have that username automatically show up.

thanks :)

Edit, figured it out myself, just adding 2 lines to login.php so not sure if it is really a hack or just a small mod

if anyone is interested, i can attach the lines here?
You really don't need to store the username in a cookie. You can use $bbuserinfo[username] almost anywhere in a template and that would show the username.

Zachery
01-22-2004, 05:43 PM
guess not.... nvm ^^



you could accomplish this by including global.php to your outside the forum pages AND a simple if stamtnet

siLk
01-22-2004, 06:30 PM
I don't want to include global.php though, i want to keep the forums seperate from the other parts of the site, but still be able to enforce the use of a username.

Either way, the way I did it works like a charm and I am very happy with it ;)

Zachery
01-22-2004, 06:40 PM
I don't want to include global.php though, i want to keep the forums seperate from the other parts of the site, but still be able to enforce the use of a username.

Either way, the way I did it works like a charm and I am very happy with it ;)
but can be spoofed very ezily :)

SteveK
01-22-2004, 07:30 PM
siLk,

Post your changes, please. Could be a simple solution to something I've been thinking about.

Thanks

siLk
01-24-2004, 04:08 AM
In login.php I added the following cookies:

replace:
if ($_REQUEST['cookieuser'])
{
vbsetcookie('userid', $bbuserinfo['userid']);
vbsetcookie('password', md5($bbuserinfo['password'] . 'L598544d'));
}

with:

if ($_REQUEST['cookieuser'])
{
vbsetcookie('userid', $bbuserinfo['userid']);
vbsetcookie('password', md5($bbuserinfo['password'] . 'L598544d'));
vbsetcookie('username', $bbuserinfo['username']);
}

and replace:
{
// we have a cookie from a user and we're logging in as
// a different user and we're not going to store a new cookie,
// so let's unset the old one
vbsetcookie('userid', '');
vbsetcookie('password', '');
}

with:


{
// we have a cookie from a user and we're logging in as
// a different user and we're not going to store a new cookie,
// so let's unset the old one
vbsetcookie('userid', '');
vbsetcookie('password', '');
vbsetcookie('username', '');
}


The users will need to log out and log back in to set this new cookie however.

So far it works very well, the cookie $bbusername is available all over my domain and I can force people to use there forum name. Also, to check if they are registerd for the forums already, anywhere on the site without including global.php, just use a simple if: (your vB cookies must be set to the whole domain for this to work)

if (isset($bbuserid)) {
arguments
} else {
echo "please register at the forums before posting here or accessing this part of the site etc";
}

By the way, if you are interested in see where / how this works, the site I am using it on is www.wcreplays.com

SteveK
01-25-2004, 05:06 AM
Nice.

Thanks