Accessing Session Vars from Included Function

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
galtian
Forum Newbie
Posts: 1
Joined: Fri Apr 20, 2007 6:35 pm

Accessing Session Vars from Included Function

Post by galtian »

Hi,
I created a function (myfunction()) in a function page (functionspage.php) that is included in my main page (main.php). I call myfunction() from main.php and in myfunction() I'm trying to access one of my session variables but I can't. At the top of both functionspage.php and main.php I start the session (session_start()). Is there a way for myfunction() to access the session variables or do I need to pass it the session variable when I call it from main.php? Thank you very much for any help.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

The array _SESSION is superglobal. You can access it from inside any function, method, ...
Post Reply