Forum Moderators: coopster

Message Too Old, No Replies

HELP : How to keep users signed in?

         

haryanto

10:44 am on May 28, 2004 (gmt 0)

10+ Year Member



Hi guys.

I have a login script that I created for my family site. How do I make a 'keep me signed in' feature for my login script? I need something secure and I have available an mySQL database.
I seen it everywhere, forums, membership sites.
Im just not smart enough to figure it out though.

All I know is I can use a PHP session ID and MySQL database. Can you guys help please?

HelenDev

1:36 pm on May 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I want people to be signed in automatically when they visit a site, I use a cookie rather than a session. I have the cookie set to expire in ten years or so, so it is practically indefinitely on their machine.

The cookie has a random number in it, which is entered into the db along with any other info they enter, like their name.

Every page checks for the cookie. If it's there it queries the db for their name etc and they get 'welcome barney!'

If it's not there you can invite them to register/log in.

WhosAWhata

11:19 pm on May 28, 2004 (gmt 0)

10+ Year Member



to look up cookie functions, [php.net...]

basic run down:
to set a cookie:

setcookie("CookieName","CookieInformation");

to read a cookie
$_COOKIE['CookieName'];

to to write a cookie and then write it to a page...

setcookie("mine","this is a message");
echo $_COOKIE['mine'];

this will write
this is a message

HOPE THIS HELPS