Page 1 of 2

PHP Rembering Login

Posted: Thu Jun 08, 2006 2:52 pm
by reecec
hi how can i make a login that rembers the username.

i have currently got it as a cookie but gamers can delete the cookie and the timer is ended.


is sesions the same as cookies

please help thanks reece

Posted: Thu Jun 08, 2006 3:02 pm
by Oren
There is nothing you can do, if one deletes the cookie he would have to log in again.
No, a session is not like a cookie. Once the browser is closed - the session doesn't exist any longer.

hi

Posted: Thu Jun 08, 2006 3:08 pm
by reecec
how would i be able to do it then so when i ad a timer they cand do anything till the time is up how would i do this with out people being able to stop the timer


thanks reece

Posted: Thu Jun 08, 2006 3:15 pm
by PrObLeM
have it when they login it saves the time. and when they do somthing have it check the time and if it is over the allowed time, log them out and redirect them to a different page.

Posted: Thu Jun 08, 2006 3:15 pm
by twigletmac
Log when the timer started in a database and check against that timestamp?

Mac

hi

Posted: Thu Jun 08, 2006 3:16 pm
by reecec
thanks

but what would i store the time in

Posted: Thu Jun 08, 2006 3:17 pm
by Li0rE
its called a database. you can use a text file or mysql

Posted: Thu Jun 08, 2006 3:18 pm
by Oren
You can't, you can have the control of your server and for the output being sent to the user's browser, but you can never have control on the user's computer.
You can set the lifetime of the session, but when the user closes the browser then the session expires - no matter what.
You may want to check: http://us2.php.net/manual/en/function.s ... params.php

hi

Posted: Thu Jun 08, 2006 3:39 pm
by reecec
yes i know a database would not work as it has to be on the users pc

how come i have tried some games and i delete the cookies close the browser and im still loged in

thanks reece

Re: hi

Posted: Thu Jun 08, 2006 3:45 pm
by PrObLeM
reecec wrote: how come i have tried some games and i delete the cookies close the browser and im still loged in
A couple of reasons ( assuming the game was browser based ):

- You didn't close all the browser windows
- You didn't delete the right cookie
- The browser just auto filled the login form and you clicked login without knowing.
- Some sort of evil dark magic.

Re: hi

Posted: Thu Jun 08, 2006 4:12 pm
by janson0
PrObLeM wrote: - You didn't close all the browser windows
- You didn't delete the right cookie
- The browser just auto filled the login form and you clicked login without knowing.
- Some sort of evil dark magic.
I vote for option 4...

Posted: Thu Jun 08, 2006 4:14 pm
by Christopher
Oren wrote:There is nothing you can do, if one deletes the cookie he would have to log in again.
No, a session is not like a cookie. Once the browser is closed - the session doesn't exist any longer.
This is not exactly true.

If you delete the cookie, but are using sessions, you can pass the session ID via the request to maintain the session.

Likewise, if there is a session cookie set, you can close the browser and reopen it and the session is maintained.

Posted: Thu Jun 08, 2006 4:22 pm
by Oren
I was talking about cookies, not session cookies.
And as far as I know, once you close the browser all sessions expire.

hi

Posted: Sun Jun 11, 2006 7:37 am
by reecec
sorry yes you right as soon as you close all browsers it logs out

thanks all

Posted: Sun Jun 11, 2006 1:05 pm
by Oren
Well... arborint is also right - it all depends on the case. Personally, I use only session cookies. I use an .htaccess file with this code in it:

Code: Select all

php_value session.use_cookies 1
php_value session.use_only_cookies 1
php_value session.use_trans_sid 0
Now, the default PHP value for the cookie lifetime is '0' = 'until the browser is closed'. So, in general, the session expires when the browser is closed as I said before, but if for some reason the cookie lifetime is set to something else, then the session wouldn't expire once the broswer is closed - in this case arborint is right :wink: