From 331a42779646618ebd6627ada5cc8298f2c74ac1 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Fri, 28 Nov 2008 01:10:41 +0000 Subject: [PATCH] BUGFIX: Better generation of PastMember cookie when you have stale login info git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@66888 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/control/Controller.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/control/Controller.php b/core/control/Controller.php index 3f821dec3..4d46f992f 100644 --- a/core/control/Controller.php +++ b/core/control/Controller.php @@ -82,9 +82,10 @@ class Controller extends RequestHandler { // Directly access the session variable just in case the Group or Member tables don't yet exist if(Session::get('loggedInAs') && Security::database_is_ready()) { - $member = Member::currentUser(); - Cookie::set("PastMember", true); - DB::query("UPDATE Member SET LastVisited = NOW() WHERE ID = $member->ID", null); + if($member = Member::currentUser()) { + Cookie::set("PastMember", true); + DB::query("UPDATE Member SET LastVisited = NOW() WHERE ID = $member->ID", null); + } } // This is used to test that subordinate controllers are actually calling parent::init() - a common bug