A session can carry an array, too, so you don’t have to keep encoding
and decoding to a string. The session itself is an associative array
object, with as many different key/value pairs as you might want to
carry around. Example:
//write the values
session_start();
$_SESSION['foo'] = $foo;
$_SESSION['bar'] = $bar;
$_SESSION['baz'] = array('baz','blah');
//read them back on another page
session_start();
$foo = ($_SESSION['foo']) || '';
$bar = ($_SESSION['bar']) || '';
$baz = ($_SESSION['baz']) || '';
Unlike a cookie, sessions can store a large amount of data. The data
is saved to a file on disk on your server. If you do this, be aware
that on a shared server, unless you have moved the default session
store location through a configuration file update into a location you
control, other users of the same server have the necessary permissions
to snoop through these files, which will also be in a known location.
That said, if you serialize the data before saving it, you can stash
an entire Object in the session, and share it around pages that way:
//trivial example, not secure
$current_user = ActiveRecord::FindFirst('users','login = "' . $login .
'"');
session_start();
$_SESSION['current_user'] = serialize($current_user);
//on another page
session_start();
$current_user = unserialize($_SESSION['current_user']);
// $current_user is now an exact replica of the object created on the
first page,
// and you don't have to look it up in the database again.
Walter
On May 28, 2010, at 12:36 PM, David Owen wrote:
That’s would be create a session,add the 3 three pieces of data as a
string, then move from page to page, adding further 3 pieces of data
onto the end of that string to create a longer string?
Will have a play and see what I can come up with.
–
David
On 28 May 2010, at 16:57, David Owen wrote:
if I wanted to take it to another level,
dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options