Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mstnorris's avatar

Save username & profile photo in session but require password

Once a user has signed up and logged in for the first time, I would like to implement the following. When a user visits my site again, I would like to present them with their username/profile photo but require that they retype their password to log in.

I would also like to implement the remember me feature too, so they have the choice.

  1. Remember me -> this automatically logs in the user
  2. Do do anything -> this will remember their username and present it to them with their photo
  3. They can choose a 'public computer' option which will remove all cookies at the end of their session.

Any help, code sample etc is much appreciated.

0 likes
1 reply
SachinAgarwal's avatar

@mstnorris For remember me feature, Laravel have it out of the box.
for present them with their username/profile photo but require that they retype their password to log in You cannot do it with sessions as sessions expire on the termination of the browser window. You can do it in multiple ways though:

  1. Keep track of IP address by storing the session. And then on every request check if there is a session from the IP and then display the name from that stored session.
    Note: You will have to figure out the way to get the internal IP address for wifi connections as, all the users connected to a router will have same IP address.

  2. You can store cookies on the users browser which will have details of last login person.
    Note: If user deletes the cookies or cookies are disabled on the browser it wont work.

for public computer option, its really very simple.
Suppose you have a check box at the login page for public computer if the check box is checked then just store the value in the session. And at the session termination check if the value is set in session, and if it is set then destroy all the cookies and other stuff you want to.

Please or to participate in this conversation.