Log out when user leaves page

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

ChrisX
New php-forum User
New php-forum User
Posts: 2
Joined: Thu Dec 19, 2002 5:48 pm

Log out when user leaves page

Postby ChrisX » Thu Dec 19, 2002 5:56 pm

Is there anyway that I can make it so that if the user goes to a site outside of mine, without logging out of mine, the user's session variables are removed and the session destroyed? (I'm using cookies sessions).

User avatar
Joan Garnet
Moderator
Moderator
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars
Contact:

Postby Joan Garnet » Fri Dec 20, 2002 6:42 pm

Well, I guess you can set the expire date of the cookie to a reasonable time.
For example 5 minutes.
So If the user keeps browsing your site, the cookie will be updated everytime he loads a new page.
If the user don't update that cookie, it'll be removed automatically.
You can also add a loggout button, but people don't use it really...

I hope it helped.
;)

ChrisX
New php-forum User
New php-forum User
Posts: 2
Joined: Thu Dec 19, 2002 5:48 pm

Postby ChrisX » Sat Dec 21, 2002 3:36 am

Yeah, I got it to work right after I posted this but thanks!

User avatar
Joan Garnet
Moderator
Moderator
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars
Contact:

Postby Joan Garnet » Sat Dec 21, 2002 10:21 am

I would use a session to do this.
It's much better for many reasons.

Code: Select all

<?php
session_start();
$username = "Joan";
$password = "my_pass";
session_register("username","password");
?>

For each page you want to use those variables, you put this code BEFORE ANYTHING on the page:

Code: Select all

<?php
session_start();
?>


byes!


Return to “PHP coding => General”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 2 guests