如何禁用Joomla 3.x中的所有访问者cookie

时间:2017-05-09 12:34:37

标签: joomla joomla3.0

我正在尝试为我的Joomla网站停用所有访客Cookie。

我找到了一些教程,但它们适用于Joomla版本:1.x

有什么建议吗?

3 个答案:

答案 0 :(得分:2)

该解决方案非常类似于在Joomla版本1.x和2.x中删除cookie的解决方案。所以我们将使用相同的条件和原则。

如果您更改这两个文件,那么其他可能无法正常工作。只有当你知道自己在做什么,并且知道其他所有工作时,才改变这一点。因为你可以打破整个网站!

您必须编辑两个文件/libraries/src/Application/CMSApplication.php和libraries / joomla / session / handler / native.php

libraries / src / Application / CMSApplication.php 中更改第166行周围的代码并添加if方法中的整个代码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
      }
}

libraries / joomla / session / handler / native.php 更改第229行附近的代码,添加if方法,如前一个文件中的方法

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
      }
 }

这适用于Joomla 3.8.2

注意:每次Joomla更新后,您必须再次编辑这两个文件并测试此解决方案是否仍然有效。

答案 1 :(得分:0)

在 Admin Joomla 设置(系统 => 配置)中设置 cookie 路径“/administrator”。 然后仅为管理区域创建会话 cookie。

答案 2 :(得分:-1)

要避免普通访问者的所有Cookie,您需要按照以下步骤操作。

First of all: Deactivate site statistics! Global configuration -> Statistics -> Statistics: No. This will stop the "mosvisitor" cookie.

Don't use the Template Chooser module, because it uses a cookie named "jos_user_template".

Be careful with components: Some might start their own PHP session. 

Now to the main point: comment out line 697 of /includes/joomla.php like this:



// setcookie( $sessionCookieName, '-', false, '/' );

附加:注释掉/offline.php中的第25行:

// session_start(); 

这种接缝是旧版本的工件。

相关问题