Another admin in another thread asked how to turn off the en4_locale and en4_language cookies as they were not used on their site. These cookies store the language and locale that is selected for site users who are not logged in.
The Social Engine code essentially does three things with each page request with regards to language and locale:
One caveat might be that a Third Party Module might use the cookies instead of the database or the site setting given that they are always available.
Therefore, if your site only has one language and locale available, you also do not need these cookies. One major advantage of turning these cookies off is that the only cookie that is used in Social Engine is that set by PHP for session management, by default called phpsessid.
At least in the UK, although likely elsewhere in the EU as the law should be similar in all of them, you are NOT required to warn users about your use of cookies or gain their consent for them, as that cookie would be covered by both the "strictly necessary" (as it is necessary for the site to function) and the "communication" exemption (as it is how PHP identifies the client endpoint). This reduces the compliance burden and user burden of ticking boxes to acknowledge (and if necessary, consent to) the use of cookies.
If you want to turn off these cookies, you will need to make a source code modification. SOCIAL ENGINE DO NOT SUPPORT SOURCE CODE MODIFICATIONS AND YOU WILL NEED TO CHECK THE SOURCE MODIFICATION EACH TIME YOU UPGRADE YOUR SITE AND IF NECESSARY, REAPPLY IT.
There are two files that you need to modify.
The first can be found at /application/modules/Core/Bootstrap.php and there are two parts of the code you need to comment out, at lines 981 to 985:
} /* elseif (!empty($_COOKIE['en4_language']) && !empty($_COOKIE['en4_locale'])) {
$locale = $_COOKIE['en4_locale'];
$language = $_COOKIE['en4_language'];
}*/ else {
and at lines 1012 to 1022:
/*
if (!$viewer->getIdentity()) {
if (empty($_COOKIE['en4_language'])) {
setcookie('en4_language', $translate->getLocale(), time() + (86400*365), '/');
}
if (empty($_COOKIE['en4_locale'])) {
setcookie('en4_locale', $locale, time() + (86400*365), '/');
}
}
*/
You will also need to edit /application/modules/Core/controllers/UtilityController.php at lines 78 and 79:
//setcookie('en4_language', $language, time() + (86400*365), '/');
//setcookie('en4_locale', $locale, time() + (86400*365), '/');
THESE CODE EDITS ARE AT THE CORRECT LOCATIONS AND TESTED WITH SOCIAL ENGINE 5.1 only.
Thank you for mentioning that source code edits will void support with SocialEngine and be overwritten or could break upgrades. Thank you also for posting your tips.
Great post and a very good description .. thank you very much.
This is a very necessary tip for me.
Thank you very much.