Created
May 28, 2014 12:10
-
-
Save ahmedsbytes/b6ba759db85319d75efd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class plgSystemVarnish extends JPlugin | |
{ | |
function onAfterRoute( ) | |
{ | |
$user = JFactory::getUser( ); | |
$option = JRequest::getVar( 'option' ); | |
if( !$user->guest || $option == 'com_users' ) | |
{ | |
setcookie( 'varnishbypass', 'True', time( ) + 604800, '/' ); | |
} | |
else | |
{ | |
setcookie( 'varnishbypass', '', time( ) - 604800, '/' ); | |
} | |
} | |
// setting the cookie in the afterRoute event is probably adequate, | |
// but in an outburst of belt and braces I decided to set/unset the | |
// cookie on the log in and out events too. Probably unnecessary, | |
// but apparently harmless. | |
function onUserLogin( $response ) | |
{ | |
setcookie( 'varnishbypass', 'True', time( ) + 604800, '/' ); | |
} | |
function onUserLogout( $response ) | |
{ | |
setcookie( 'varnishbypass', '', time( ) - 604800, '/' ); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment