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:
Did you know?Explore Trending and Topic pages for more stories like this.
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
want to add a break after a certain amount of characters
i was wondering how to add a break in a blog post after a certain amount of characters... any idea o
Downloading file (Headers)
I'm trying to make users download a file, but they must wait 60 seconds before it begins.
But
Select question
Hi,
First I would like to say that php is pretty new for me..
so please don't shoot me if
Problem with coding MySQL query
I'm having heaps of trouble getting one of my PHP/MySQL queries to work for some reason (and the fun
mail() problem
Hi Guys,
I've set up a contact email form. It sends the information fine, but it sends it to
Loosing changed contents when used FM REUSE_ALV_GRID_DISPLAY
Hi,
I have used FM REUSE_ALV_GRID_DISPLAY in my program as below.
CALL FUNCT
Automatic Webpage ??
I have a page www.mysite.com/test.php with a
<form>
<textarea name=&q
php or sql?
Sorry not sure if this is a sql problem or php the following code is supposed to delete data from th
do while conditions
i want to display 6 images in a 2x3 table
now what would be the correct logic to
count that th
How to change www in url with a specified name
Hi
I'm trying to change the url http://www.sitename.com/apparels to something like below
http: