How to get rid of the session expire in Joomla

How to get rid of the session expire in Joomla. Joomla has added a function since 1.5 version to keep session alive while editing or creating articles,messages,managing media,etc.

The function lacated in libraries/joomla/html/html/behavior.php

If you want use the function to make your extension "keep alive",simply add

JHtml::_('behavior.keepalive');
 

at the beginning of the page.

See the code of the function of keepalive bellow:

/**
* Keep session alive, for example, while editing or creating an article.
*
* @return  void
* @since  1.5
*/
public static function keepalive()
{
static $loaded = false;
 
// only load once
if ($loaded) {
return;
}
 
// Include mootools framework
self::framework();
 
$config  = JFactory::getConfig();
$lifetime  = ($config->get('lifetime') * 60000);
$refreshTime = ($lifetime <= 60000) ? 30000 : $lifetime - 60000;
//refresh time is 1 minute less than the liftime assined in the configuration.php file
 
// the longest refresh period is one hour to prevent integer overflow.
if ($refreshTime > 3600000 || $refreshTime <= 0) {
$refreshTime = 3600000;
}
 
$document = JFactory::getDocument();
$script = '';
$script .= 'function keepAlive() {';
$script .= '  var myAjax = new Request({method: "get", url: "index.php"}).send();';
$script .= '}';
$script .=  ' window.addEvent("domready", function()';
$script .=  '{ keepAlive.periodical('.$refreshTime.'); }';
$script .= ');';
 
$document->addScriptDeclaration($script);
$loaded = true;
 
return;
}
 
 

Add comment


Security code
Refresh

Latest comments

  • Kee 09.06.2013 04:23
    Hi Simon, Thanks for the feedback. EasyTagCloud v2.4.1 work well in most of the environment but there ...
     
  • Simon Greener 08.06.2013 12:56
    I have installed v2.4.1 but get php errors in administration and front-end pages: Notice: Undefined index ...
     
  • truongduong201 08.06.2013 02:52
    I got it, thank you Kee
     
  • Kee 01.06.2013 11:58
    最新的2.4版已经修正了此问题
     
  • Kee 01.06.2013 11:57
    Hi Oleg, v2.0 was an old version that released almost two years ago,the blacklist worked when I tested ...

Contact & Support

Kee Huang

Email: This email address is being protected from spambots. You need JavaScript enabled to view it.