Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Browser Persistent Data with PHP - Final Quiz

Hey just wondering if anyone can help me out with one of the Final Quiz questions.

QUESTION: How can one access the session variable named "treehouse"?

I've tried imputing: session_start(); and setcookie

but I just get "Bummer! Unfortunately, that answer is incorrect." What am I missing? I've re watched the proceeding videos multiple times but I just can't work out what the answer is.

I guess you can access session like this $_SESSION['treehouse']

1 Answer

Matthew Lang
Matthew Lang
13,483 Points

Make sure you have start_session(); at the beginning.

You can access the $_SESSION superglobal like a normal array. E.g $_SESSION['treehouse']

Great! Thanks to both of you for pointing me in the right direction. My mistake was imputing '$_SESSION' without adding the array to the end. Ashu Singh has the correct syntax as Matthew Lang's code is missing the underscore ..but still very helpful, Thank you.