Topic: How is cookie read?

Hello, I'm making additions to my copy of PunBB, and I wanted to know how the read the cookie that is set. I've read the code in the functions.php file numerous times, but I can't figure out how the cookie is actually read. I know that the "userid" is set in the cookie, but how would I go about extracting that value?

Thank you.

Without programming, I would have nothing to do...nahhhh

Re: How is cookie read?

This is what I am currently using and all it does is show the error message.

$result = $db->query('SELECT contactban FROM '.$db->prefix.'users WHERE id='.$cur_user['user_id']) or error('Unable to select from database', __FILE__, __LINE__, $db->error());
Without programming, I would have nothing to do...nahhhh

3

Re: How is cookie read?

Sam Rusch wrote:

This is what I am currently using and all it does is show the error message.

$result = $db->query('SELECT contactban FROM '.$db->prefix.'users WHERE id='.$cur_user['user_id']) or error('Unable to select from database', __FILE__, __LINE__, $db->error());

There is no contactban value in the database:

http://punbb.org/docs/dev.html

Re: How is cookie read?

Moved to PunBB Discussion

Re: How is cookie read?

MattF wrote:
Sam Rusch wrote:

This is what I am currently using and all it does is show the error message.

$result = $db->query('SELECT contactban FROM '.$db->prefix.'users WHERE id='.$cur_user['user_id']) or error('Unable to select from database', __FILE__, __LINE__, $db->error());

There is no contactban value in the database:

http://punbb.org/docs/dev.html

I know, it is something that I added in myself already.

Without programming, I would have nothing to do...nahhhh

Re: How is cookie read?

Sam Rusch wrote:

Hello, I'm making additions to my copy of PunBB, and I wanted to know how the read the cookie that is set. I've read the code in the functions.php file numerous times, but I can't figure out how the cookie is actually read. I know that the "userid" is set in the cookie, but how would I go about extracting that value?

Thank you.

The cookie is a serialized string which contains an array with 2 elements: the user_id and the password_hash

Re: How is cookie read?

Smartys wrote:
Sam Rusch wrote:

Hello, I'm making additions to my copy of PunBB, and I wanted to know how the read the cookie that is set. I've read the code in the functions.php file numerous times, but I can't figure out how the cookie is actually read. I know that the "userid" is set in the cookie, but how would I go about extracting that value?

Thank you.

The cookie is a serialized string which contains an array with 2 elements: the user_id and the password_hash

I know that, but how would I be able to extract those values seperately? Or, actually, what I want to do is just take out the user_id value so I can add some things to the forums. Begin to make my own mods.

Without programming, I would have nothing to do...nahhhh

Re: How is cookie read?

This is code taken directly from PunBB wink

    // If a cookie is set, we get the user_id and password hash from it
    if (isset($_COOKIE[$cookie_name]))
        list($cookie['user_id'], $cookie['password_hash']) = @unserialize($_COOKIE[$cookie_name]);

Re: How is cookie read?

Smartys wrote:

This is code taken directly from PunBB wink

    // If a cookie is set, we get the user_id and password hash from it
    if (isset($_COOKIE[$cookie_name]))
        list($cookie['user_id'], $cookie['password_hash']) = @unserialize($_COOKIE[$cookie_name]);

I saw that, I swear, but I did not know if that was the right thing to look at. Wow, now I look totally stupid. Thank you.

Without programming, I would have nothing to do...nahhhh

Re: How is cookie read?

No problem smile

Re: How is cookie read?

This is something that I will be using a lot in my next mod to PunBB. I hope all goes well, and I can do something good this time smile

Without programming, I would have nothing to do...nahhhh

12 (edited by Frank H 2007-04-15 20:21)

Re: How is cookie read?

hmm ... are you relying on cookie id to enter information into the database? (if so a security risk, as ppl can make their own cookies)

(it's much better to use PunBB's own variables, as those has been checked so that the user is who he says he is)

Re: How is cookie read?

Frank H wrote:

hmm ... are you relying on cookie id to enter information into the database? (if so a security risk, as ppl can make their own cookies)

(it's much better to use PunBB's own variables, as those has been checked so that the user is who he says he is)

Hmm, could you explain more about these variables? Can I contact you in another form, such as an IM client? I want to talk to someone personally who knows PunBB very well so I can better understand it.

Without programming, I would have nothing to do...nahhhh