views:

75

answers:

2

OK, so here's the snippet:

                // start rememberMe
    $cookie_name = 'db_auth';

    $cookie_time = (3600 * 24 * 30); // 30 days

    // check to see if user checked box
    if ($remember == 1) {
setcookie ($cookie_name, 'username='.$username., time() + $cookie_time);
    }

For some reason it breaks and I can't see why. It is part of a larger function which works fine when I comment this snippet out. Any ideas?

+5  A: 

You have an extra dot after "$username" in the second last line.

oggy
That doesn't seem to have fixed it...
musoNic80
Hang on! Tried it again - and works perfectly. Not sure what I did first time i tried it.... :)
musoNic80
php -l will syntax-check a file
Ken Keenan
A: 

try putting parentheses around your arguments for setcookie?

like this:

setcookie ($cookie_name, ('username='.$username), (time() + $cookie_time));

untested, but maybe the plus sign is causing your issue?

This is also assuming that the rest of your code is ok. Usually php throws errors, so if you're getting a blank page, the first place I would look is your page source.

Jesse
alas not. Just tried it. I also tried putting double inverted commas around the username bit.
musoNic80
are you getting any errors at all?
Jesse