Php,session about the problem, $_session can't get the data, how

Source: Internet
Author: User
Php,session problem, $_session can not get the data, what is going on?
Class Admin {
Private $name;
Public Function SetName ($name) {
$this->name = $name;
}
Public Function GetName () {
return $this->name;
}
}
Admin.class.php
?>

Require_once ' Admin.class.php ';
Session_Start ();
$admin = new admin ();
$admin->setname ("Mike");
$_session[' class '] = $admin; Save the Admin object to the session


This is the file session.php the main object is to put objects in the session
?>

Require_once ' Admin.class.php ';
Session_Start ();
$admin = $_session[' class '];
echo "
";
Print_r ($_session); This is mainly to see if the session file is stored in the object, through the output certificate saved
echo "
";
echo $admin->getname ();//But here the GetName () method does not take the corresponding data
session2.php remove the file from the session
?>






Array
(
[Class] = Admin Object
(
[Name:Admin:private] = Mike
)


)//This is the content saved in the session file. Mike, this data is saved.

------Solution--------------------
Don't listen to others.
Your code is actually executed to prove that there are no problems.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.