Topic: Help with cookie processing.

I'm starting a new thread for my problem because I wasn't getting any help in the last one. Also, the name of the topic was irrelevant.

<?php
$pun_root = './';
define('PUN', 1);
include "include/common.php";

echo $cur_user['username'];
?>

This should work for displaying the name of the current user on any page if it was included. Why doesn't it?

Any suggestions would be appreciated.

I don't HAVE a signature, ok?

Re: Help with cookie processing.

It will work if the user is logged in. However, if he is not, then $cur_user will not be set. Try something like this:

if ($cookie['is_guest'])
    echo 'Hello guest';
else
    echo 'Hello '.pun_htmlspecialchars($cur_user['username']);
"Programming is like sex: one mistake and you have to support it for the rest of your life."

3 (edited by creaturecorp 2004-12-13 15:59)

Re: Help with cookie processing.

Thankyou very much for your reply. Sorry for being impatient. wink I'll try it when I get a chance. If it doesn't work this time I'll give up on it all together.

Btw, you made a mean forum. Keep up the good work.

I don't HAVE a signature, ok?

Re: Help with cookie processing.

This is a truly fascinating problem. I put exactly what you had plus the includes, but even when I'm logged in it still says welcome guest. There are no errors or warnings.

It's in the forum directory, and all the links are valid, and no errors. I'm thinking of giving up. Please let me know what you think is still wrong with it. (In rational thought, it looks like a completely sensible and correct way of connecting and displaying the name) Also, I apologize again for being rude. smile

I don't HAVE a signature, ok?

Re: Help with cookie processing.

you testing this in the same domain as the forum?

6 (edited by creaturecorp 2004-12-13 21:48)

Re: Help with cookie processing.

It worked perfectly this time, and it's obvious the domain was the reason for the malfunction. (I don't know why it would make a difference, but ok) I salute you! I should have thought of it before! Thank you so much for pointing that out. Thanks Rickard and Connorhd for your responses, and have a nice day.

I don't HAVE a signature, ok?

Re: Help with cookie processing.

lol well cookies are stored by domain name... so think about it wink

Re: Help with cookie processing.

I'd better go back and learn php again. smile Rotfl

I don't HAVE a signature, ok?