HttpSession on java allow me to store an object, then i try it on php and it can be done as well. Very simple as follow:
this listing show you the object registered in session
<?php
$user = new User();
$user = $userControl->getUser($userId,$password);
# CREATE USE SESSION
session_start();
session_register("currentUser");
$_SESSION['currentUser'] = $user;
# GO TO THE OTHER PAGE
header("Location: View/index.php");
?>
As you know that variable $user is an object, right? and it has been stored in session. Then in index.php writen as follow:
<?php
function __autoload( $u="user" ) {
include("../Model/".$u.".php");
}
$user = new User();
$user = $_SESSION['currentUser'];
echo $user->getUserName();
?>
Don’t forget to write session_start() above them. Function __autoload( <parameter> ) will automaticaly call the function which hasn’t been defined yet. By calling this function the scripting engine is given a last chance to load the class before PHP fails with an error.
That’s all for this time.
ThanksAlot – Djöllkè





Recent Comments