How to create a login system that is still logged in (until the user is logged out) even though the browser stopped has gone?
When using How Yahoo, Facebook, Twitter or any site prepares its login system, so when a user is browsing the browser, will it be logged in? Using IP? $ _SESSION? $ _COOKIE? As told by Oswald, code> $ _ session , because It ends when the browser closes. Session variables are stored in the form of cookies, so make your own When creating your own A huge abundance of the production site uses cookies for the session, just make sure that your session keys are random enough that can not be estimated by any other client. EDIT How to Use View This Link The following will set the session code for your website with Your value will be stored in the next section, this will be the session key that you will store in the database and will match the user, now will be The next part is up to the end of time, here I have kept $ _ session , when this browser was closed, we could use
$ _COOKIE But it seems that the session is less secure then.
less secure is not.
cookie , you should set an end to one year or so, to ensure that the time does not expire, and User will be in login
setkey ("session_key", "somerandomstringrepresentingasessionkey", time () + 60 * 60 * 24 * 120);
session_key , in this way you will get data on the runtime:
< Code> $ session = $ _COOKIE ['session_key'];
$ Sessions .
60 * 60 * 24 * 120 , which means that the current time, plus 60 seconds, bar 60 minutes, Times 24 hours, time 120 days Which means that in that 120 days of that exact time of time, that specific cookie will expire, even though the browser has stopped earlier.
No comments:
Post a Comment