Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 2000051

[PHP3] Sessions and cookies help From: Nikki Chang (vb_gal21 <email protected>)
Date: 05/15/00

Hi all,

I'm new to php. I'm doing something on session
management. How do I check "get" a user's session id
rom the browser? If the user has no id, the
following code will generate an id and store it into a
database. I was told to use the $GLOBALS function but
I have no idea how. Please help. This is urgent.

function set_browser_id(){

    $session_id = utime().get_date();
    SetCookie($session_id);
    store_new_browser_id($session_id);
}
 
function store_new_browser_id($id){

  $sql = "INSERT INTO users(session_id)
values('$id')";
  mysql_query($sql, $db);
}
 
Someone suggested to ensure "double protection", I
should also check for the existence of a database
session id before writing to the database. If an id
exists, the system should generate a new id and
write the user session id to this database id. How can
I implement this? THanks in advance.

Regards,
Nikki

__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/

-- 
PHP 3 Mailing List <http://www.php.net/>
To unsubscribe, send an empty message to php3-unsubscribe <email protected>
To subscribe to the digest, e-mail: php3-digest-subscribe <email protected>
To search the mailing list archive, go to: http://www.php.net/mailsearch.php3
To contact the list administrators, e-mail: php-list-admin <email protected>