1
試圖爲我的cakephp應用程序開發某種登錄跟蹤器。如何在登錄後(和重定向之前)添加一些操作?
我知道,我需要這樣的代碼:
$this->data['LoginSession']['username'] = $_SERVER['REMOTE_ADDR'];
$this->data['LoginSession']['ipAddress'] = $_SERVER['REMOTE_ADDR'];
$this->LoginSession->save($this->data);
...在(我猜)users_controller,但並不確切地知道哪裏。
我也想跟蹤成功,但也不成功的登錄。
你能幫助我嗎?先謝謝你!
我有東西simular函數:$ this-> Auth-> loginRedirect =陣列( '控制器'=> '出版物');但是,登錄工作正常,與此問題。我只是想添加這個新功能來跟蹤所有的登錄嘗試。 – user198003 2010-06-16 06:48:44
然後在'if($ this-> Auth-> user()){'。 – bancer 2010-06-16 08:37:15
如果啓用了'$ this-> Auth-> autoRedirect'(默認設置),AuthComponent將爲您處理重定向(無需運行'login()'動作或進行任何跟蹤)。如果你想自己處理重定向(帶有額外的跟蹤代碼),那麼你需要關閉autoredirect。看到最後一個例子:http://book.cakephp.org/view/1274/autoRedirect – deizel 2010-06-16 13:02:23