2

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

I need to work on an existing website with a connected user:

<?php session_start();
print_r($_SESSION); ?>

This code outputs:

Array([%http_user%] => Array
    (
        [profile_id] => 72
        [username] => john
        [session_id] => 4ek79umrrpael7vvb4ls3diaq4
    )

[registration_invite_code] => 

)

That's what I need. It try to get "john" into my $username variable:

any idea how ?

I've tried with:

$_SESSION[0]

$_SESSION["%http_user%"]

$_SESSION->username

No way.

Any way how to retrieve this username ?

Thanks

Community
  • 1
  • 1
yarek
  • 11,278
  • 30
  • 120
  • 219
  • Tried print_r on $_SESSION['%http_user%'], I think username is in that array e.g.$_SESSION['%http_user%']['username'] ? – David Nov 07 '12 at 23:08

1 Answers1

3

$variable = $_SESSION['%http_user%']['username'];

Paul Dessert
  • 6,363
  • 8
  • 47
  • 74