joomlajoomla3.0

How to disable all visitors cookies in Joomla 3.x


I'm trying to disable all visitor cookies for my Joomla website.

I found some tutorials, but they are for Joomla version:1.x

Any suggestions?


Solution

  • The solution is very similar to solution to remove cookies in Joomla version 1.x and 2.x. So we will use the same condition and principle.

    If you change this two files then maybe something other will not work. Change this only if you know what are you doing and if you know that will everyting else work. Because you can break the whole website!

    You must edit two files /libraries/src/Application/CMSApplication.php and libraries/joomla/session/handler/native.php

    In libraries/src/Application/CMSApplication.php change code around line 166 and add if condition for whole code in method if (substr($_SERVER['SCRIPT_NAME'] , 0 , 14) == "/administrator"){

    public function checkSession()
        {
          if (substr($_SERVER['SCRIPT_NAME'] , 0 , 14) == "/administrator"){ // added condition
            $db = \JFactory::getDbo();
            $session = \JFactory::getSession();
            $user = \JFactory::getUser();
    
                // ... rest of code
          }
    }
    

    In libraries/joomla/session/handler/native.php change code around line 229 add if condition for whole code in method like in previous file

    private function doSessionStart()
        {
          if (substr($_SERVER['SCRIPT_NAME'] , 0 , 14) == "/administrator"){ // added condition
            // Register our function as shutdown method, so we can manipulate it
            register_shutdown_function(array($this, 'save'));
    
            // ... rest of code
          }
     }
    

    This works in Joomla 3.8.2

    Note: after every Joomla update you must edit this two files again and test if this solution still works.