Session Data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chewy509

    Session Data

    Hi All,

    I'm having a small problem with sessions, or in particular some of the
    data is not being saved within the session data.

    To be exact, 1 variable from within an object is not being saved, but
    all the other varibles within the same object are. Having a look at
    the created session file, shows an unusual field relating to the
    varible in question.

    Session Data:
    HRM_App|O:7:"hr m_app":9:{s:5:" state";a:0:{}s: 7:"user_id";s:2 :"19";
    s:8:"username"; s:17:"d.smith"; s:4:"dept";s:1: "1";s:4:"comp"; s:1:"2";
    s:13:"user_secu rity";i:1;s:3:" msg";s:0:"";s:1 5:"defaultRedir ect";s:0:"";
    s:3:"cfg";a:11: {s:6:"dbtype";s :5:"mysql";}}

    The odd one out is: s:13:"user_secu rity";i:1; where all the other
    fields have the following format: s:3:"msg";s:0:" ";

    When I query that field later on, it returns "1", not the value that
    it's initialised with as part of the application login procedure
    (which also sets the other variables as well).

    So can someone explain what the "i" indicates, what's going on, and a
    possible fix?

    TIA, Chewy509.

    PS. PHP 4.3.2 on Win2K with IIS.
    PPS. I've searched for a description of the session file format used
    by PHP, but can't find one anywhere? If someone knows of a link, then
    it would be appreciated to pass on that info.
  • R. Rajesh Jeba Anbiah

    #2
    Re: Session Data

    Chewy509@austar net.com.au (Chewy509) wrote in message news:<339c079c. 0403091640.114a a230@posting.go ogle.com>...[color=blue]
    > Session Data:
    > HRM_App|O:7:"hr m_app":9:{s:5:" state";a:0:{}s: 7:"user_id";s:2 :"19";
    > s:8:"username"; s:17:"d.smith"; s:4:"dept";s:1: "1";s:4:"comp"; s:1:"2";
    > s:13:"user_secu rity";i:1;s:3:" msg";s:0:"";s:1 5:"defaultRedir ect";s:0:"";
    > s:3:"cfg";a:11: {s:6:"dbtype";s :5:"mysql";}}
    >
    > So can someone explain what the "i" indicates,[/color]

    IIRC, integer.

    --
    "I don't believe in the God who doesn't give me food, but shows me
    heaven!"--Swami Vivekanandha
    Email: rrjanbiah-at-Y!com

    Comment

    • Justin Koivisto

      #3
      Re: Session Data

      Chewy509 wrote:
      [color=blue]
      > The odd one out is: s:13:"user_secu rity";i:1; where all the other
      > fields have the following format: s:3:"msg";s:0:" ";
      >
      > When I query that field later on, it returns "1", not the value that
      > it's initialised with as part of the application login procedure
      > (which also sets the other variables as well).
      >
      > So can someone explain what the "i" indicates, what's going on, and a
      > possible fix?[/color]

      One thing that may help you determine what is happening is to do a
      var_dump of the $_SESSION array. Then you can see in human terms what
      each variable is. From what I see above, $_SESSION['user_security'] = int(1)

      If you are expecting a string, make sure you have quotes around the
      value when assigning it to the variable. Short of that, there really
      isn't enough information for more help.

      --
      Justin Koivisto - spam@koivi.com
      PHP POSTERS: Please use comp.lang.php for PHP related questions,
      alt.php* groups are not recommended.
      SEO Competition League: http://seo.koivi.com/

      Comment

      • Chewy509

        #4
        Re: Session Data

        Justin Koivisto wrote in message...[color=blue]
        > Chewy509 wrote:
        >[color=green]
        > > The odd one out is: s:13:"user_secu rity";i:1; where all the other
        > > fields have the following format: s:3:"msg";s:0:" ";
        > >
        > > When I query that field later on, it returns "1", not the value that
        > > it's initialised with as part of the application login procedure
        > > (which also sets the other variables as well).
        > >
        > > So can someone explain what the "i" indicates, what's going on, and a
        > > possible fix?[/color]
        >
        > One thing that may help you determine what is happening is to do a
        > var_dump of the $_SESSION array. Then you can see in human terms what
        > each variable is. From what I see above, $_SESSION['user_security'] = int(1)
        >
        > If you are expecting a string, make sure you have quotes around the
        > value when assigning it to the variable. Short of that, there really
        > isn't enough information for more help.[/color]

        I found out what was causing it, a fault in one of the php scripts,
        was assigning the variable a value, instead of comparing the value,
        (the classic: "if ($user_security = 1) {" instead of "if
        ($user_security == 1) {" ).

        I guess I should have looked harder at all the scripts that use this
        variable?

        Thanks again.

        Comment

        Working...