On Tue, 13 Jul 2004 17:52:44 +0100, Harlequin
<[EMAIL PROTECTED]> wrote:
> I'm right in the middle of developing some pages that will require session
> cookies. Now I have a few questions and hope I don't bore you too much...
> 
> I presume I am right in assuming that I can declare variables anywhere I
> like providing I have started a session on the page but I cannot actually
> use those variables until a post or some similar action has been performed
> by the user.
> 
> I am also wondering if I need to declare all my variables one after the
> other or can I simply declare variables that I will be using immediately
> upon submission.
> 

I'm not quite sure what your question is, but here's some info. You
have to call session_start() before using anything in the session.
This must be called before there is any output to the browser.

After the call to session_start() you can get/set/unset any session
value you want at any time in the script (all of this is stored on the
server). The best way to do all of this is through the $_SESSION
superglobal. Use it like a normal assicative array:

$_SESSION['var'] = 'value';

or:

$_SESSION['array'] = array(1, 2, 3, 4);

os:

$_SESSION['object'] = new Object();

Everything you put in there will be available from any function
without having to use the global keyword or the $GLOBALS superglobal.

Note that you can't store recources in the session (at least, they
can't be used as resources on subsequent requests.) This includes
things such as open file desriptors and database connections or
statement handles.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to