Retreiving objects from Sessions
Posted on
16th Feb 2014 07:03 pm by
admin
Hi all,
I am getting really frustrated with storing and retreiving objects from a session. But it may be because of my lack of knowledge in sessions
First some system specs:
OS - Vista Home 32bit
Webserver - IIS 7
PHP - PHP 5.2.11
php.ini
session.auto_start = 1
So, when I decide to store an object array in the session, it works just fine. I can also retrieve it from the session but with an extra attribute mentioning: "__PHP_Incomplete_Class_Name" with the value of the Object Name.
Code when I try to retrieve object from session:
Code: $hits = $_SESSION['hitsArray']; // Array of MyObject
AMethodThatDoesSomething($hits[0]); // Requires MyObject Type
And this is where it fails:
I get following information in the debugger:
__PHP_Incomplete_Class_Name | MyObject
Attribute 1 | A value
Attribute 2 | Another Value
....And so on....
Ok, so I did some research and found out objects do not work if you have "session.auto_start = 1" in php.ini
AND that you need to add following line above your session_start():
Code:
require_once("MyObject.php");
session_start();
header("Cache-control: private");
session_register('hitsArray'); // Array of MyObject
$_SESSION['hitsArray'] = $hits; // Store into session
So, I changed "session.auto_start = 0" in php.ini and added the required line above. Well then it didn't even store my object array in the session in the first place!
Now I feel that I am stumbling in the dark and hope for someone to be able to help me in my ordeal!
No comments posted yet
Your Answer:
Login to answer
246
49
Other forums
problem with query error
First Thanks to those who helped me on my previous posts, and the following code i'm using is not mi
User feedback after MySQL query has been executed
Hi all, I've just registered on PHPFreaks because I've got a question that I simply can't work out b
need help with date function
i have following form for date
Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Inserting into MySQL Newbie
Hi ive got a slight problem where ive made a simple web form where the customer inserts the ammount
Create a form of 2 numbers input and find the greatest.
Hi, everybody.
I have a homework in my training of php, which ask you to make a form that ask
strtotime issue
Hey all,
I'm playing around with some code, and basically the idea is:
Person changes
Get dump of MySQL DB from Live Site
I'm after an easy, but secure way of generating and importing a MySQL dump from a remote server.
Is this possible? If one file assigned to an ID...
I have a page that lists property listings assigned to a specific user (a manage page), with brief t
what are '%S%', '%E%'
for example when i see Code: [Select]printf("Hello %srn", $name);
what does %s means
Displaying Column Names
I have a question regarding the ability to show the column names from my table/query.
What I'm lo