Topic: Login issue - Tried multiple solutions from forum

Hello...

I have set up a new forum and am having the login issue that many other people have mentioned where a user logs in successfully, is redirected back to the main page, but then is not actually logged in.  This seems to be happening for a number of users, in both Firefox and IE.  It was working successfully for a week or so before this behavior started.  Here is what I have tried so far:

1.  Clear cache
2.  Clear cookies
3.  Uncomment the P3P line in functions.php
4.  Reupload login.php
5.  Check $cookie_domain = ''

Also, I have commented out the unregister_globals function to allow for some other site functionality.  As far as I know, it was still working after that.

You can view the site here:  http://www.grupofantasma.com/forum/index.php

Thanks for your help,

Adam

Re: Login issue - Tried multiple solutions from forum

Did you edit the check_cookie function at all?

Re: Login issue - Tried multiple solutions from forum

Nope...  not that I am aware of at least.

Re: Login issue - Tried multiple solutions from forum

What is your cookie_domain set to?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Login issue - Tried multiple solutions from forum

Rickard: His cookie domain is set to '', at least from what his post says.
I logged in to a test account. The cookie is there, it's set and it stays set. The issue is that PunBB doesn't seem to be reading the cookie properly

Re: Login issue - Tried multiple solutions from forum

He should try:

$cookie_domain = '.grupofantasma.com';

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Login issue - Tried multiple solutions from forum

I tried a few variations for $cookie_domain and none seemed to work:

.grupofantasma.com
grupofantasma.com
www.grupofantasma.com
grupofantasma
.grupofantasma

Also, the cookie path is:  $cookie_path = '/';

Is this possibly related to the unregister_globals function being commented out?

Thanks so much for your help...  Hope I can get this worked out soon...

Re: Login issue - Tried multiple solutions from forum

It shouldn't have anything to do with that, the cookie is being placed perfectly
Could you paste your copy of the check_cookie function?

Re: Login issue - Tried multiple solutions from forum

Here is the check_cookie function:

function check_cookie(&$pun_user)
{
    global $db, $pun_config, $cookie_name, $cookie_seed;

    $now = time();
    $expire = $now + 31536000;    // The cookie expires after a year

    // We assume it's a guest
    $cookie = array('user_id' => 1, 'password_hash' => 'Guest');

    // 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]);

    if ($cookie['user_id'] > 1)
    {
        // Check if there's a user with the user ID and password hash from the cookie
        $result = $db->query('SELECT u.*, g.*, o.logged, o.idle FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON u.group_id=g.g_id LEFT JOIN '.$db->prefix.'online AS o ON o.user_id=u.id WHERE u.id='.intval($cookie['user_id'])) or error('Unable to fetch user information', __FILE__, __LINE__, $db->error());
        $pun_user = $db->fetch_assoc($result);

        // If user authorisation failed
        if (!isset($pun_user['id']) || md5($cookie_seed.$pun_user['password']) !== $cookie['password_hash'])
        {
            pun_setcookie(0, random_pass(8), $expire);
            set_default_user();

            return;
        }

        // Set a default language if the user selected language no longer exists
        if (!@file_exists(PUN_ROOT.'lang/'.$pun_user['language']))
            $pun_user['language'] = $pun_config['o_default_lang'];

        // Set a default style if the user selected style no longer exists
        if (!@file_exists(PUN_ROOT.'style/'.$pun_user['style'].'.css'))
            $pun_user['style'] = $pun_config['o_default_style'];

        if (!$pun_user['disp_topics'])
            $pun_user['disp_topics'] = $pun_config['o_disp_topics_default'];
        if (!$pun_user['disp_posts'])
            $pun_user['disp_posts'] = $pun_config['o_disp_posts_default'];

        if ($pun_user['save_pass'] == '0')
            $expire = 0;

        // Define this if you want this visit to affect the online list and the users last visit data
        if (!defined('PUN_QUIET_VISIT'))
        {
            // Update the online list
            if (!$pun_user['logged'])
                $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$now.')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
            else
            {
                // Special case: We've timed out, but no other user has browsed the forums since we timed out
                if ($pun_user['logged'] < ($now-$pun_config['o_timeout_visit']))
                {
                    $db->query('UPDATE '.$db->prefix.'users SET last_visit='.$pun_user['logged'].' WHERE id='.$pun_user['id']) or error('Unable to update user visit data', __FILE__, __LINE__, $db->error());
                    $pun_user['last_visit'] = $pun_user['logged'];
                }

                $idle_sql = ($pun_user['idle'] == '1') ? ', idle=0' : '';
                $db->query('UPDATE '.$db->prefix.'online SET logged='.$now.$idle_sql.' WHERE user_id='.$pun_user['id']) or error('Unable to update online list', __FILE__, __LINE__, $db->error());
            }
        }

        $pun_user['is_guest'] = false;
    }
    else
        set_default_user();
}

******************************************************
Also, I have included the setcookie function (just to make sure) since I uncommented the P3P section:

function pun_setcookie($user_id, $password_hash, $expire)
{
    global $cookie_name, $cookie_path, $cookie_domain, $cookie_secure, $cookie_seed;

    // Enable sending of a P3P header by removing // from the following line (try this if login is failing in IE6)
    @header('P3P: CP="CUR ADM"');

    setcookie($cookie_name, serialize(array($user_id, md5($cookie_seed.$password_hash))), $expire, $cookie_path, $cookie_domain, $cookie_secure);
}

Re: Login issue - Tried multiple solutions from forum

Odd, it looks fine to me
I'd need FTP access to try and find the issue

11 (edited by Smartys 2006-06-14 14:49)

Re: Login issue - Tried multiple solutions from forum

For anyone curious, I ended up finding the issue: adam added a require line for the wordpress header at the top of common.php. I moved it down to the bottom and... no issues.

Edit: And sadly, I'm not familiar enough with the way WordPress works to figure out why it was an issue wink

Re: Login issue - Tried multiple solutions from forum

Smarty & Rickard - Thanks for all the help...  Much appreciated.  I'll be rolling out the site soon.

13

Re: Login issue - Tried multiple solutions from forum

I have basically the same problem,so what should i do? smile

Re: Login issue - Tried multiple solutions from forum

Are you using Wordpress and trying to combine it with PunBB?

15

Re: Login issue - Tried multiple solutions from forum

No.i  just have tha same proble m like:I have set up a new forum and am having the login issue that many other people have mentioned where a user logs in successfully, is redirected back to the main page, but then is not actually logged in.  This seems to be happening for every user, in IE.


Clear cache
Clear cookies
Uncomment the P3P line in functions.php
Check $cookie_domain = ''

the address is http://fak_kkg.extra.hu maybe it can help you a bit smile