joomla - 如何在 Joomla 3.x 中禁用所有访问者 cookie

标签 joomla joomla3.0

我正在尝试为我的 Joomla 网站禁用所有访问者 cookie。

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

有什么建议吗?

最佳答案

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

如果您更改这两个文件,那么其他文件可能不起作用。仅当您知道自己在做什么并且知道其他一切都会起作用时才更改此设置。因为你可以破坏整个网站!

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

libraries/src/Application/CMSApplication.php 中,更改第 166 行附近的代码,并在方法 if (substr($_SERVER['SCRIPT_NAME'] , 0 , 14) 中为整个代码添加 if 条件== "/管理员"){

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 更新后,您必须再次编辑这两个文件并测试此解决方案是否仍然有效。

关于joomla - 如何在 Joomla 3.x 中禁用所有访问者 cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43869982/

相关文章:

php - 如何将android连接到joomla数据库

joomla - 无法获取 Joomla 3 中的模块 ID

javascript - 为什么 Joomla 不会加载我的自定义 JavaScript?

php - Joomla 3.0 菜单 fatal error

joomla - 如何在 Joomla! 中创建用户特定的内容! 3.0?

javascript - Joomla iFrame 动态高度

php - 在页面刷新/关闭之前设置 cookie

mysql - mysql 5.5 上的 joomla 1.5.22

php - fatal error : Class 'JDatabaseDriver' not found

html - 使用 div 创建 CSS 树