0

Possible Duplicate:
forcing access to __PHP_Incomplete_Class object properties
Able to see a variable in print_r()'s output, but not sure how to access it in code

I would like to ask for some advice on how to parse a system generated array which I got from session.

when I do print_r($_SESSION); here's what I've got.

Array (
    [user] => __PHP_Incomplete_Class Object (
        [__PHP_Incomplete_Class_Name] => DEX_User
        [permissionID:DE_User:private] => 9
        [login:DE_User:private] => James.S
        [email:DE_User:private] => james.s@domain.com
        [firstName:DE_User:private] => James
        [lastName:DE_User:private] => Steal
        [title:DE_User:private] => Warehouse Man
        [manager:DE_User:private] => Manager's Name
        [workPhone:DE_User:private] => +1 (111) 111-1111
        [mobilePhone:DE_User:private] => +1 (222) 222-2222
        [homePhone:DE_User:private] => +1 (333) 333-3333
        [im:DE_User:private] =>
        [timeDelta:DE_User:private] => Asia/Hongkong
        [lastLogin:DE_User:private] => __PHP_Incomplete_Class Object ( 
            [__PHP_Incomplete_Class_Name] => GB_Date
            [valueStored:protected] => 13545544126666309821
            [mode:protected] => BASE
            [master:protected] =>
        )
        [description:DE_User:private] => Warehouse Engineer
        [isActive:DE_User:private] => __PHP_Incomplete_Class Object (
            [__PHP_Incomplete_Class_Name] => GB_Boolean
            [valueStored:protected] => 1
            [mode:protected] => BASE
            [master:protected] =>
        )
        [isTerminate:DE_User:private] => __PHP_Incomplete_Class Object (
            [__PHP_Incomplete_Class_Name] => GB_Boolean
            [valueStored:protected] =>
            [mode:protected] => BASE
            [master:protected] =>
        )
        [id:protected] => 231968
        [isModifyed:protected] => 
        [needInsert:protected] => 
        [isDeleted] => 
        [isRemoved] => 
    )
    [enter_password] => 2asas(qwqw
)

What I would like to achieve is to get 3 items from the array.

I want to get the data

login = James.S
firstName = James
lastName = Steal

Thanks a lot.

Community
  • 1
  • 1
webdev.gk
  • 209
  • 1
  • 4
  • 10

1 Answers1

0

You can't.

Examine this piece of code:

[login:DE_User:private] => James.S
[firstName:DE_User:private] => James

The login and first name are private properties of a object, that is not accessible from the outside.

JvdBerg
  • 21,777
  • 8
  • 38
  • 55
  • Unless you can edit the class and write a "getter" function for it $user->getName() (or, see if it already has a Getter function, try doing a `get_class_methods()` on the class to see what's available) – Martin Lyne Oct 26 '12 at 09:08
  • 1
    Or convert it to an array: [Array to Object and Object to Array in PHP - interesting behaviour](http://stackoverflow.com/q/6325447/367456) – hakre Oct 26 '12 at 09:09
  • oh so even if it is already exposed in the session still I can't get the data. – webdev.gk Oct 26 '12 at 09:14
  • looks like I can't do anything on this as I don't have access to the source code. What I can do right now is to ready the session then parse it. – webdev.gk Oct 26 '12 at 09:50
  • You could take the session as a string and try to regex it. Doable .. but messy. – JvdBerg Oct 26 '12 at 09:52