Re: Problem with sessions.(Again Sorry :)

From: Date: Sun, 21 Jul 2002 05:05:05 +0000
Subject: Re: Problem with sessions.(Again Sorry :)
Groups: php.general 
Request: Send a blank email to php-general+get-108696@lists.php.net to get a copy of this message
>I have a login script which calls this function if it is a proper user etc. > >function register_in_session($uinfo){ >// Used in conjuction with validate to input user info into the session > $_SESSION['uid'] = $uinfo[0]; > $_SESSION['gid'] = $uinfo[1]; > $_SESSION['banid'] = $uinfo[2]; > $_SESSION['username'] = $uinfo[3]; > $_SESSION['fname'] = $uinfo[4]; > $_SESSION['lname'] = $uinfo[5]; > $_SESSION['email'] = $uinfo[6]; >} Don't cram things into $_SESSION. Use this: session_register('uid'); global $uid; $uid = $uinfo[0]; >as a test i use this function in all my pages. > >function welcome_or_login(){ >if(isset($_SESSION['fname'])){ > echo 'Hello '.$_SESSION['fname'].'.'; > } else { > do_h('Login', 3, 'y'); > do_hr(); > login_form(''); > } >} > >Only on the login page my test user's name is displayed. On all other pages >it reverts to the login form. You didn't register them -- You just crammed some arbitrary junk into $_SESSION. The variable $uid didn't have any value in it. -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#108696) next »