NYCPHP Meetup

[nycphp-talk] Problems writing session variables

Hans Zaunere hans at nyphp.org
Thu Apr 3 16:06:52 EST 2003


--- Daniel Porcher <danporcher at earthlink.net> wrote:
> Can anyone tell me why I can't successfully write out session variables.
> 
> I'm test in a Windows AMP environment. I doublechecked the session folder
> in
> php.ini and I'm successfully creating and deleting the sessions themselves.
> When I look at the variables in the session file after I execute the code
> below, all I see is:
> 
> !ses_user|
> 
> 
> The code:
> 
> <?php
> 
> session_start();
> 
> loginuser();
> 
> function loginuser()
> {
> 
>    global $_POST;
>    global $_SESSION;

This is unneeded, and may be your problem (although I'm pretty PHP would just
ignore it).  $_POST and $_SESSION are superglobals: they are available in all
scopes.

>    $userid = $_POST['userid'];
>    $passwd = $_POST['passwd'];
> 
>    //I validate user against DB here, if valid I write out session
> variables

Double check that you're actually getting what you expect:
var_dump($userid);
var_dump($passwd);

>    $_SESSION['ses_user'] = $userid;
>    $_SESSION['ses_access'] = odbc_result($rsSecurity,'AccessType');
>    $_SESSION['ses_orgtype'] = odbc_result($rsSecurity,'OrgType');
>    $_SESSION['ses_orgid'] = odbc_result($rsSecurity,'OrgID');

This should work, although I would double check that the odbc_result() calls
return what you expect before investigating it as session troubles first. 
var_dump(); is your friend.

H


> }
> 
> 
> Thanks,
> 
> Dan
> 
> 
> Daniel Porcher
> President
> Watershed Web Design
> 
> Website: http://www.watersheddesign.com
> E-mail: dporcher at watersheddesign.com
> Phone: 609-466-0266
> 
> "A ship in harbor is safe, but that is not what ships are built for."
> 
> 
> 
> 
> --- Unsubscribe at http://nyphp.org/list/ ---
> 
> 




More information about the talk mailing list