Forum Moderators: coopster
This means sessions, of course, and that's what I've been using so far for the array. As far as I know, serialisation/deserialisation is done automatically in PHP, so I don't need to do that (I'm using PHP 4.3.6).
That is to say, would this work?
//page 1
include 'userClass.php'
session_start();
$user =& new userClass();
//do login stuff, whatever.
$_SESSION['user'] = $user;
//page 2
include 'userClass.php';
session_start();
$_SESSION['user']->callMethod();
By the way, if anyone thinks the array's a better idea, do let me know.
Cheers,
Alex ...
##### declare: ########
session_start();
$username=$_POST['username'];
$_SESSION['username'] = $username;
###### use it: #########
session_start();
Possibly I did not understood your quest?
regards
Henry
//get user name
print $_SESSION['user']->getUserName();
Instead of:
//get user name
print $_SESSION['user']['userName'];
There's really not much to it, I just seem to find that passing class methods around rather than variables seems to be a bit cleaner. Especially as if I change $_SESSION['userName'] to just $_SESSION['name'], it doesn't matter much if I was just calling an object method (since that wouldn't be renamed).
There's no real advantage, like I said. Cleaner code, possibly. Just asking if I'd got it right, that's all. Maybe in the next code overthrow I do of my site I might put this in.
Cheers,
Alex ...