我正在尝试禁用我的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 中的整个代码添加 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 条件 在方法中为整个代码添加 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更新后,您必须再次编辑这两个文件,并测试此解决方案是否仍然有效。
在 Admin Joomla 设置(系统 => 配置)中设置 cookie 路径"/administrator"。 然后,仅为管理区域创建会话 Cookie。
为避免普通访问者使用所有 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, '/' );
附加:注释掉/脱机.php中的第 25 行:
// session_start();
这个接缝是旧版本的工件。