By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,643 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

Classes, serialization, sessions and security...

P: n/a

I have a class that needs to effectively have global data so that different
instances of the class on different pages share the same data. The following
class is not the real thing, but the two functions I'm using are the ones
listed here. They are: store_session and retrieve_session.....


class page_info

var $a_var;
var $another_var;

function set_vars()
$this->a_var = "this is a test";
$this->another_var = "this is also a test";

function show_vars()
echo $this->a_var . " " . $this->another_var;

function store_session()
$_SESSION[session_id()] = serialize($this);
function retrieve_session()
$this = unserialize($_SESSION[session_id()]);




include 'class.php';

$cls_page_info = new page_info;




include 'class.php';

$cls_page_info = new page_info;

This works beautifully. But is it a nice way of doing it? Is it insecure?
Are there better ways of sharing data between pages?

Any advice greatly appreciated.


Jul 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.