Session Question

From: Date: Wed, 14 Jun 2000 16:26:24 +0000
Subject: Session Question
Groups: php.version4 
Request: Send a blank email to php-version4+get-16285@lists.php.net to get a copy of this message
I have a funciton in the begining of the page which checks that a variable "id" is registered in a session.. in the first pagei strat a new session and set the idto 1 and register the variable.. function set_id($user,$pwd) { global $id; $db = new FumarelDb(); $query="select cod_usuario from usuarios where username='$user' and pwd='$pwd'"; if(!$db->query($query)>0) return false; $db->next(); $id=$db->f("cod_usuario"); session_start(); session_register("id"); return $id; } and then in the other page trying this way function get_id() { global $id; session_start(); if(!session_is_registered("id")) return false; echo $id; return $id; } doesn't output nothing .. but changing the global line.. function get_id() { session_start(); if(!session_is_registered("id")) return false; global $id; echo $id; return $id; } outputs the rigth id... Why? what am i doing wrong??

« previous php.version4 (#16285) next »