Session Array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
allen01
Forum Newbie
Posts: 4
Joined: Wed Feb 20, 2008 2:50 am

Session Array

Post by allen01 »

How can i retrieve the password value from this session array. I tried something like $_SESSION['fc_users_cache'][1]['password'] but it's not working. I can easily get the user_name by doing $_SESSION['user']['user_name'] but i'm not able to get the password. Any help would be greatly appreciated.
I did a print_r($_SESSION); to get the following

***** PLEASE USE THE

Code: Select all

TAG WHEN POSTING *****[/color]
 

Code: Select all

Array
(
    [user] => Array
        (
            [user_id] => 1
            [user_name] => admin
            [time_zone] => 0
        )
 
    [url] =>
    [admin] => Array
        (
            [is_logged_in] => 1
        )
 
    [pstart] => 0
    [vstart] => 0
    [astart] => 0
    [mstart] => 0
    [fstart] => 0
    [fc_users_cache] => Array
        (
            [1] => Array
                (
                    [user_id] => 1
                    [user_name] => admin
                    [password] => adminpass
                    [referrer_id] => 0
                    [first_name] => admin
                    [last_name] => admin
                )
 
        )
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Session Array

Post by Christopher »

$_SESSION['fc_users_cache'][1]['password'] should work, but there is something strange going on on the next line at ['email']???
(#10850)
allen01
Forum Newbie
Posts: 4
Joined: Wed Feb 20, 2008 2:50 am

Re: Session Array

Post by allen01 »

The email part was a typo. I edited the thread and removed it. I did $_SESSION['fc_users_cache'][1]['password'] but for some reason it's just not pulling up the value.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Session Array

Post by Benjamin »

Post your code, it's in the array so the code pulling it out must have a glitch.
allen01
Forum Newbie
Posts: 4
Joined: Wed Feb 20, 2008 2:50 am

Re: Session Array

Post by allen01 »

The code is simple. All i want to do is pull the value.

session_start();
$pass = $_SESSION['fc_users_cache'][1]['password'];
echo $pass;
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Session Array

Post by Benjamin »

Post the actual code.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Session Array

Post by Christopher »

Is it possible that it is: $_SESSION['fc_users_cache']['1']['password'] which is actually $_SESSION['fc_users_cache'][0]['password'] ???
(#10850)
Post Reply