Forum

Thread tagged as: Question, Members

Members App - Automatic login for registered members if cookie found

Using the Members App, is it possible to automatically log a user in if an "auto login" cookie is detected?

Once the user registers we would set a cookie to record their registration on the device. Then anywhere that the code tests for a logged in member using perch_member_logged_in() we would also test for the cookie and automatically log them in if the cookie was found.

Thanks.

Ian Buchanan

Ian Buchanan 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, set PERCH_MEMBERS_SESSION_TIME to be the lifetime of the cookie.

define('PERCH_MEMBERS_SESSION_TIME', '30 DAYS');

Hi Drew,

Thanks for the reply.

Can I just check: all I need to do is add that line into the config.php file?

I guess that using this I can't have any finer control per member e.g. the option for the user to auto login or not?

Thanks.

Drew McLellan

Drew McLellan 2638 points
Perch Support

It's not auto login, it's setting the lifetime of the session cookie. You can log members out, of course.