3

I want to disable session for all guests or public visitors which are being stored to joomla's session table in order to reduce hits and serverload. In fact, my website doesn't have front-end log-in nor user access which means I don't have to worry about CSRF nor other attacks since no authentication is required.

I have tried many different settings and optimization such as removing unused extensions (components/modules/plugins) and switching $session_handler to memcached or none(file) but with no luck and the session table keeps growing especially when bots and crawlers are hijacking the traffic.

I have found some hacky workarounds after googling, for e.g. Disabling Joomla Session on Guest/Public (Joomla 3.x) . However, those are unlikely the recommended approaches.

Many have also requested a feature to disable the behavior and the issue can be found on Joomla's Github page: see Please make possible to disable the default Joomla behavior of creating sessions for 'guest users' in the db #8772.

Please guide me if there is any solution or not at all?

  • 1
    A simple modification in the /libraries/joomla/session/storage/database.php file can help reduce the write significantly to the session table. We have written how to do that here: itoctopus.com/… . At this time, I do not think that this can be resolved without a core modification. Just keep a record of the modified files and you'll be fine. – itoctopus Jul 11 '16 at 23:43
3

Another way to reduce the server load is to make the session table of memory type. You need to set mysqls heap size quite large and convert the blob field in session into a large varchar, say 15000 length.

I had great results with this.

Another option is to use memcache and something like elasticache

0

You have destroyed session of your website at all time?
Kindly below code copy to paste your template index.php

<?php
$session =JFactory::getSession(); // starting the session
$session->destroy(); //This will destroy the joomla session
?> 

Read the below documentation
https://docs.joomla.org/API15:JSession/destroy

  • I don't want to destroy joomla session but to disable storing it in db – kolunar Jul 13 '16 at 18:11
0

If you don't want to go with some sort of core hack, then I would look at creating a trigger on the session table itself. Something like this should work but is not tested.

CREATE TRIGGER `delete_before` 
BEFORE INSERT ON `j25_session`
FOR EACH ROW 
BEGIN 
IF(NEW.`guest` = 1) THEN 
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'your error message';
END IF; 
END;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.