Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[php] zend_session::rememberMe

Joined
Sep 10, 2006
Messages
2,817
Reaction score
1,417
Mk, hi, my login system is bit session-side(checking if the user is online with session, etc). But I needed to make a "remember me" function, so I've used zend's feature to remember session. But it's acting strange. Here few test I did.

When I login:

$session->id
= session1(4e6e63c355fdf575625fc25bb4a84f64)

user's session in db
= session1
(4e6e63c355fdf575625fc25bb4a84f64)

session set in browser(with expire exactly as I wanted with zend_session::rememberMe)
= session2(5161c629555e62a7796753fd795e47b5)

after about 30 minutes:

$session->id
= session1(4e6e63c355fdf575625fc25bb4a84f64) somehow changes to session2(5161c629555e62a7796753fd795e47b5)
which cause a log offbecause the session in db is still session1

Bit hard to explain, but anyone know what's going on? Why the zend_session became the _real?_ one after 30 minutes?

PHP:
<?php

set_include_path
(
    get_include_path()
    . PATH_SEPARATOR . '/Zend'
);

include('Zend/Session.php');

Zend_Session::start();
xmysql_connect();

$session = new Zend_Session_Namespace('fmscms');
global $session;
if( !isset($session->id) )
{
    $session->id = Zend_Session::getId();
}
PHP:
        if( $encpwd == $dbpwd ) 
        {   
            $query         = "UPDATE user SET session='".$session->id."', lastlogin = NOW() WHERE username='$user'";
            $result2     = mysql_query($query);
            if( $stayloggedin )
            {
                Zend_Session::rememberMe(60 * 60 * 24 * 30 * 6);                
            }
            else
            {
                Zend_Session::rememberMe(3600);
            }
            index_redir();
        }
This is the session which is set after checked stay logged in check box.. (Zend_Session::rememberMe(60 * 60 * 24 * 30 * 6); )
foxx - [php] zend_session::rememberMe - RaGEZONE Forums


but this is the $session->id; immedatly after login
foxx - [php] zend_session::rememberMe - RaGEZONE Forums
 
Joined
Sep 10, 2006
Messages
2,817
Reaction score
1,417
Fixed, :lock: ploz.

(15:41:18) King Bunneh: add after
(15:41:28) King Bunneh: $session->id = Zend_Session::getId();
(15:41:46) King Bunneh: $session->setExpirationSeconds(<same time here as in rememberMe()>);
(15:41:55) King Bunneh: that should work
(15:42:57) King Bunneh: i think the problem was, that the session namespace was expiring before the actual session, so when you would do if isset $session->id, it wouldn't be set since the namespace expired, so it would be changed to the new session id
 
Back
Top