Click to See Complete Forum and Search --> : Session variable scope


Anon
04-30-2001, 12:58 AM
Using Windows 2000 and PHP 4

I have a page with the following structure

index.php
-- session_start()

-- include/application.inc
---- define vars here

-- include/buildFramework.inc
---- function to build HTML uses session vars

The session vars are scoped and accessible in index.php but they are not available in buildFramework.inc

Is this is general issue in PHP or is there some other way to code this that I should be aware of?


TIA

Anon
04-30-2001, 01:06 AM
Let me clarify the issue a bit more

buildFramework.inc includes a series of functions. the sessions vars are available outside the functions but not in the functions themselves.

Anon
04-30-2001, 01:13 AM
Make sure that you are declaring the variables "global" in the functions. Otherwise the function(s) will be working with uninitialized local variables of the same names.

-- Michael
Darkstreak Consulting
www.darkstreak.com

Anon
04-30-2001, 01:16 AM
Well just chalk it up to me inexperience with PHP. I didn't declare the session vars as globals inside the functions so they weren't availabe.