我正在尝试为我的 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/