top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Getting Objects out of the $SESSION variable unscathed in PHP

+2 votes
67 views

I'm having a problem getting my objects out of the $SESSION variable. I am storing an ordinal array of associate arrays where one of the associate array elements is an object. Unfortunately, when I pull it back out, the object is "broken" with "__PHP_Incomplete_Class" errors.

From what I can read this has something to do with 'serialization' - i.e., the emerging object must be unserialized (http://php.net/manual/en/function.unserialize.php ). However, I can't get it to work.

Any tips on how that is done, or what I should do instead?

This program is being developed on a testing server that can then be put on a production server.

Here are my server specs:
Apache Version : 2.2.17
PHP Version : 5.3.3
MySQL Version : 5.5.8

posted Feb 12, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

For those objects to be unserialised the class must already have been included, otherwise PHP can't reconstruct it correctly. The error indicates that the class does not exist.

answer Feb 24, 2015 by Vrije Mani Upadhyay
Similar Questions
0 votes

I have the following (below) session code at the top of each page.. The 'print_r' (development feature only) confirms that on one particular page I do log out as the session var = (). but, on testing that page via the URL I still get to see the page and all its contents - session var() -.. the page has the following session_start, DOCTYPE Info then containing meta info

error_reporting (E_ALL ^ E_NOTICE);
$userid = $_SESSION['userid'];
$username = $_SESSION['username'];
print_r($_SESSION);
0 votes

I want to write online user module for my site and I want to check $_SESSION['userID'] to find all users id who loged in but when I echo this code its return only current user detail how I can see all sessions?

foreach($_SESSION as $k => $v)
{
echo $k."----------".$v;
}

or how I handle online users?

0 votes

I am having trouble with session vars. I'm trying to implement the credit card direct pay method outlined here...

http://developer.authorize.net/api/dpm/

Basically, page 1 is my form that goes outside my site to the cc gateway company then comes back with a result... (PG2)

Problem: if I try to create session vars on page 1 - they don't work on page 2.

Am I correct in thinking that when this process leaves my site and goes to the gateway, then returns, it is similar to creating a new session and that is why the session vars don't remain active?

...