Re: sessions problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

   When someone hit the logout page say "logout.php".
You can write the code in that page itself to update
the record. Since the username of that particular user
is stored as a session as long as the user closes the
browser window.

So in the logout page you can add like this.....

session_start();
include("connect.php");
$uname=$_SESSION['username'];
$sql = mysql_query("UPDATE users SET online='0'
 WHERE username='$uname'");

//alternatively u can also delete that particular user
from the database instead of updating the online
status to '0'.

I hope this might help you.

Regards
..Deeps..

--- Anasta <neretlis@xxxxxxxxxxxxxx> wrote:
> Anyone know how to update a record on logout, heres
> what i am using for
> login, however there iare no variables for the
> logout page.
> 
> ?
> session_start();  // Start Session
> 
> include("connect.php");
> 
> $username = $_POST['username'];
> $password = $_POST['password'];
> 
>    // Register some session variables
>    session_register('username');
>    $_SESSION['username'] = $username;
>  //sets user online to yes
> $sql = mysql_query("UPDATE users SET online='1'
> WHERE username='$username'
> AND password='$password'");
> 
>    if (($username == "admin") And ($password ==
> "admin")) {
>     header("location: login_admin.php");
>    } else {
>     header("location: login_success.php");
>    }
> 
> ?>
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

________________________________________________________________________
Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux