-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnginxcache.php
More file actions
46 lines (45 loc) · 1.17 KB
/
nginxcache.php
File metadata and controls
46 lines (45 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* @package Joomla.Plugin
* @subpackage System.jds
*
* @copyright Copyright (C) 2015 DZ Creative Studio. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Joomla! JDS Plugin.
*
* @package Joomla.Plugin
* @subpackage System.JDS
* @since 1.5
*/
class PlgSystemNginxCache extends JPlugin
{
/**
* Set cookies JSESSION on front-end if logged in
* Disable cache if logged in or in back-end
*
* @return void
*
* @since 3.0
*/
public function onAfterInitialise()
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
if ($app->isAdmin()) {
$app->allowCache(false);
} else if (!$user->guest) {
$app->allowCache(false);
if (!$app->input->cookie->get('JSESSION')) {
$app->input->cookie->set('JSESSION', true);
}
} else {
$app->allowCache(true);
if ($app->input->cookie->get('JSESSION')) {
$app->input->cookie->set('JSESSION', NULL, time() - 1);
}
}
}
}