Is it possible to disable session handling in Joomla 1.5 for guests?
I do not use user system in the front end, i assumed that it's not needed to run queries like below:
Site will use APC or Memcache as caching system under heavy load, so it's important for me.
DELETE FROM jos_session WHERE ( time < '1274709357' )
SELECT * FROM jos_session WHERE session_id = '70c247cde8dcc4dad1ce111991772475'
UPDATE `jos_session` SET `time`='1274710257',`userid`='0',`usertype`='',`username`='',`gid`='0',`guest`='1',`client_id`='0',`data`='__default|a:8:{s:15:\"session.counter\";i:5;s:19:\"session.timer.start\";i:1274709740;s:18:\"session.timer.last\";i:1274709749;s:17:\"session.timer.now\";i:1274709754;s:22:\"session.client.browser\";s:88:\"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3\";s:8:\"registry\";O:9:\"JRegistry\":3:{s:17:\"_defaultNameSpace\";s:7:\"session\";s:9:\"_registry\";a:1:{s:7:\"session\";a:1:{s:4:\"data\";O:8:\"stdClass\":0:{}}}s:7:\"_errors\";a:0:{}}s:4:\"user\";O:5:\"JUser\":19:{s:2:\"id\";i:0;s:4:\"name\";N;s:8:\"username\";N;s:5:\"email\";N;s:8:\"password\";N;s:14:\"password_clear\";s:0:\"\";s:8:\"usertype\";N;s:5:\"block\";N;s:9:\"sendEmail\";i:0;s:3:\"gid\";i:0;s:12:\"registerDate\";N;s:13:\"lastvisitDate\";N;s:10:\"activation\";N;s:6:\"params\";N;s:3:\"aid\";i:0;s:5:\"guest\";i:1;s:7:\"_params\";O:10:\"JParameter\":7:{s:4:\"_raw\";s:0:\"\";s:4:\"_xml\";N;s:9:\"_elements\";a:0:{}s:12:\"_elementPath\";a:1:{i:0;s:74:\"C:\\xampp\\htdocs\\sites\\iv.mynet.com\\libraries\\joomla\\html\\parameter\\element\";}s:17:\"_defaultNameSpace\";s:8:\"_default\";s:9:\"_registry\";a:1:{s:8:\"_default\";a:1:{s:4:\"data\";O:8:\"stdClass\":0:{}}}s:7:\"_errors\";a:0:{}}s:9:\"_errorMsg\";N;s:7:\"_errors\";a:0:{}}s:13:\"session.token\";s:32:\"a2b19c7baf223ad5fd2d5503e18ed323\";}'
WHERE session_id='70c247cde8dcc4dad1ce111991772475'
I probably found out the answer:
You can add a second argument to the line in /index.php
/**
* CREATE THE APPLICATION
*
* NOTE :
*/
$mainframe =& JFactory::getApplication('site');
change this line as;
$mainframe =& JFactory::getApplication('site',array('session'=>false));
This will close session handling in frontend only, and also you can set session handler to a cache mechanism like APC,Memcache.I prefer APC.
I had this same problem and wanted to disable guest sessions in frontend but retain sessions in backend. As well i found out that google and other bots make lots of page request and then create session and our session table was gettin too big.
Solution (Not that nice, but works)
I replaced function insert (libraries/joomla/database/table/session.php)
with
function insert($sessionId, $clientId) {
$url = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
$this->session_id = $sessionId;
$this->client_id = $clientId;
$this->time = time();
if ($this->guest!=1 || stristr($url,'/administrator'))
$ret = $this->_db->insertObject( $this->_tbl, $this, 'session_id' );
if( !$ret && $this->guest!=1) {
$this->setError(strtolower(get_class( $this ))."::". JText::_( 'store failed' ) ."<br />" . $this->_db->stderr());
return false;
}
else {
return true;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With