How to save sessions in the browser

Asked

Viewed 98 times

1

How to record sessions in the browser with php.

Currently I have a login system, and always validates [$_SESSIONS] existing in the browser, but every time I close and open the browser again, the login no longer exists.

How best to save data in the browser.

  • It will be useful to use COOKIES?
  • I must save sessions in Database?

What is the best way to do this process, for whenever you log in you never have to log in?

  • What I would do: Save the user and password of the guy who logged in to the cookie and when he logs in, see if you have Session, if you don’t have it, you create it

  • That doesn’t sound very reliable. Let’s say I log into another user’s PC, see their credentials, then just copy the cookies to my PC and always access their account without really knowing the password.

  • 1

    save a random secret code to a persistent cookie after the first login, also saving the hash of that cookie in your database. If a user accesses the site without being logged in, but has a valid code, then it is considered that it is the same user returning to the site and you automatically authenticate it. See https://answall.com/questions/85566/op%C3%A7%C3%A3o-keep-connected Remind me

1 answer

0

Sessions whenever you close the browser it will be closed. If you want something longer lasting use Cookies, you can configure how long it is available, even by closing the browser. See more about cookies on:

http://php.net/manual/en/features.cookies.php

Browser other questions tagged

You are not signed in. Login or sign up in order to post.