anjanesh
anjanesh

Reputation: 4251

Retain same session id as before

session_start();

I create an entry in the database and the user can edit it online..
Now, the user has closed the browser. And tomorrow he opens it and goes to the same site.
Is it possible to retain the same session id as before so that he can edit the same data, rather than having to goto the beginning ?

Upvotes: 0

Views: 88

Answers (1)

Abu Yousef
Abu Yousef

Reputation: 570

A solution that is often used, in this situation, is to :

  • have a not too long session duration : it will expire if the user is not active (that's just the way it works -- and that's better for your server if you have lots of users)
  • when user logs in, you set a cookie that contains what is needed for him to be recognized
  • if he comes back on the site (with the cookie, and without having an active session), you use the informations contained in that cookie to auto-log him in, re-creating the session at the same time.

This way :

  • you don't have thousands of sessions "active" with no good reason you keep the standard way sessions work
  • And you have the advantage of "never being looged out", at least from the user's point of view.

Upvotes: 1

Related Questions