Auto Logout (V 4.0)

joymax27104000

New Member
YetiShare User
Jun 4, 2014
131
0
0
Auto Logout (V 4.0)
Every time my users download and try and download again it logs them out, I tested and it does it for me as well any fix for this?
 

coffee

New Member
Jul 23, 2014
83
0
0
Try turning off the account sharing option in settings if you have it on.

Also try turning the logout setting time up some in settings. Also match it to session.gc-maxlifetime in your php.ini file.
 

dfdssfsfd3806

Member
YetiShare User
Apr 4, 2014
271
0
16
it comes from the site because there was something in front to avoid its uncomment and they removed it unfortunately my members are also constantly disconnected
 

dfdssfsfd3806

Member
YetiShare User
Apr 4, 2014
271
0
16
it is a code made ​​quickly but his work has to do until a patch placed her at the top of page

<? $userinfo = $_COOKIE['filehosting'];

if($userinfo) {
$db = Database::getDatabase();

$row1 = $db->getRow('SELECT * FROM sessions WHERE id = ' . (int)$userinfo.' LIMIT 1');
$userToImpersonate2 = $row1['user_id'];

$db = Database::getDatabase();

$row = $db->getRow('SELECT * FROM users WHERE id = ' . (int)$userToImpersonate2.' LIMIT 1');

if (is_array($row))
{
$rtt->id = $row['id'];
$rtt->username = $row['username'];
$rtt->email = $row['email'];
$rtt->level_id = $row['level_id'];
$rtt->level = UserPeer::getLevelLabel($rtt->level_id);
$rtt->paidExpiryDate = $row['paidExpiryDate'];
$rtt->paymentTracker = $row['paymentTracker'];

// load any additional user info if DBObject and User are available
$rtt->user = new User();
$rtt->user->id = $row['id'];
$rtt->user->load($row);



}

//if (headers_sent())
//{
// die('Error: Headers already sent, can not set session data. rtt is likely due to a config file or plugin file which has been damaged on upload with extra spacing in it.');
// return false;
//}

$_SESSION['user'] = serialize($rtt);

}
?>
 

dfdssfsfd3806

Member
YetiShare User
Apr 4, 2014
271
0
16
this code works I corrected

Code:
<? $userinfo = $_COOKIE['filehosting'];

 if($userinfo) {
        $db           = Database::getDatabase();

$row1 = $db->getRow("SELECT * FROM sessions WHERE  `id` LIKE  '" .$userinfo."'  LIMIT 1");
$userToImpersonate2 = $row1['user_id'];

        $db     = Database::getDatabase(); 
      
            $row = $db->getRow('SELECT * FROM users WHERE id = ' . (int)$userToImpersonate2.' LIMIT 1');
       
        if (is_array($row))
        {
            $rtt->id             = $row['id'];
            $rtt->username       = $row['username'];
            $rtt->email          = $row['email'];
            $rtt->level_id       = $row['level_id'];
            $rtt->level          = UserPeer::getLevelLabel($rtt->level_id);
            $rtt->paidExpiryDate = $row['paidExpiryDate'];
            $rtt->paymentTracker = $row['paymentTracker'];

            // load any additional user info if DBObject and User are available
            $rtt->user     = new User();
            $rtt->user->id = $row['id'];
            $rtt->user->load($row);

        

 }

        //if (headers_sent())
        //{
        //    die('Error: Headers already sent, can not set session data. rtt is likely due to a config file or plugin file which has been damaged on upload with extra spacing in it.');
        //    return false;
        //}

        $_SESSION['user'] = serialize($rtt);
    
	 }
?>
 

dfdssfsfd3806

Member
YetiShare User
Apr 4, 2014
271
0
16
put up in
_header.inc.php and _header_file_manager_top_inc.php

<?
if ($Auth->loggedIn())
{
setcookie("user", "".$Auth->user->username."", time()+60*60*24*25, "/");
setcookie("pw", "".$Auth->user->password."", time()+60*60*24*25, "/");
}
$user = $_COOKIE['user'];
$pw = $_COOKIE['pw'];

if($user) {
$db = Database::getDatabase();
$row = $db->getRow("SELECT * FROM users WHERE username = '". $user."' and password = '". $pw."' LIMIT 1");
if (is_array($row))
{
$rtt->id = $row['id'];
$rtt->username = $row['username'];
$rtt->email = $row['email'];
$rtt->level_id = $row['level_id'];
$rtt->level = UserPeer::getLevelLabel($rtt->level_id);
$rtt->paidExpiryDate = $row['paidExpiryDate'];
$rtt->paymentTracker = $row['paymentTracker'];

// load any additional user info if DBObject and User are available
$rtt->user = new User();
$rtt->user->id = $row['id'];
$rtt->user->load($row);
}
$_SESSION['user'] = serialize($rtt);
}
?>
then in logout.html

setcookie("user", '', time() - 31536000,"/");
setcookie("pw", '', time() - 31536000,"/");
$Auth->logout();
coreFunctions::redirect(WEB_ROOT);
 

joymax27104000

New Member
YetiShare User
Jun 4, 2014
131
0
0
@ dfdssfsfd3806: thank you very much. And I hope Adam can release update version to fix this problem
 

coffee

New Member
Jul 23, 2014
83
0
0
This has worked for me (has to be done on all servers):

You can hard code it by editing /core/includes/dBSession.class.php. Find:
Code:
if((int)$max < 60)
{
    $max = 60*60*24*7; // 7 days
}
Replace with:
Code:
$max = 60*60*24*14;
 

coffee

New Member
Jul 23, 2014
83
0
0
Ah CF. Yeah some users have an issue with CF. I never did. Users would be logged out with or without it. That fixed it up for me.
 

will1901

New Member
YetiShare User
Nov 1, 2012
8
0
0
Thx coffee, perfect fix for me.

Surprising though, the default session.gc_maxlifetime is 1440 (1440 seconds = 24 minutes), and this only sets the logout time to 7 days if session.gc_maxliftime is less than 60 seconds. I'm surprised more people don't have this issue with sessions and users getting logged out. (specially with users with slow connections)