How can I update the user records on login in CakePHP? -
I am new to CakePHP and frameworks and I have tried Google in search of an answer without any luck.
I am using the empty login () function and want to be able to change user records on login (like last_login). How can I go about doing this?
If you are using an athlete component of cake, first you have to use the following in your first filtered function Enter a line:
$ this-> AUTH- & gt; Auto redirect = false; By setting it to false, kppp's login function will allow the execution of the following code after completing its magic.
Add to your login function:
if ($ this-> AUTH- & gt; user ()) {$ this- & gt; User- & gt; Id = $ this- & gt; Auth-> User ('id'); $ This- & gt; User- & gt; Savefield ('last_login', date ('Y-M-DH: I: S')); } Note: Make sure that you have received the last login field in your Consumer Table and set its date to datetime.
Comments
Post a Comment