Welcome Guest, Not a member yet? Register   Sign In
CI 1.7 Session Bug within object storage
#21

[eluser]salbertson[/eluser]
Thanks hSATAC and Brant, you made my day.
#22

[eluser]sramos[/eluser]
[quote author="littleram" date="1242012460"][quote author="lukeinjax" date="1234830581"]I am experiencing this same issue. I've added the MY_Session file with the code above to my libraries folder, but I'm getting the following error:

Code:
A PHP Error was encountered

Severity: 4096

Message: Object of class __PHP_Incomplete_Class could not be converted to string

Filename: libraries/MY_Session.php

Line Number: 71

Anyone else having this issue?[/quote]


This happens if you initialise the session before you've loaded the class definitions for the object you're trying to save into the session. Ensure that you've include()'d or require()'d all the class definitions before you load the session library.[/quote]

Im facing this problem, do you mean to use:
Quote:include 'libraries/the-class-i-want-to-store';

inside my controller and before my controller class definition?
#23

[eluser]seegithub[/eluser]
Yeah... you're dewa brooo!!!!
#24

[eluser]MVUG[/eluser]
Issue is fixed in trunk...

https://bitbucket.org/ellislab/codeignit...ot-working
#25

[eluser]farinspace[/eluser]
found a better solution which supports deep arrays, seems like this is waiting for a CI 3.0 release.

see: https://github.com/EllisLab/CodeIgniter/pull/583

MY_Session.php

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

// https://github.com/EllisLab/CodeIgniter/pull/583

class MY_Session extends CI_Session {

function _escape_slashes(&$val, $key)
{
  if (is_string($val))
  {
   $val = str_replace('\\', '{{slash}}', $val);
  }
}

function _serialize($data)
{
  if (is_array($data))
  {
   array_walk_recursive($data, array(&$this, '_escape_slashes'));
  }
  else
  {
   if (is_string($data))
   {
    $data = str_replace('\\', '{{slash}}', $data);
   }
  }

  return serialize($data);
}

function _unserialize($data)
{
  $data = @unserialize(strip_slashes($data));

  if (is_array($data))
  {
   array_walk_recursive($data, array(&$this, '_unescape_slashes'));

   return $data;
  }

  return (is_string($data)) ? str_replace('{{slash}}', '\\', $data) : $data;
}

function _unescape_slashes(&$val, $key)
{
  $val = str_replace('{{slash}}', '\\', $val);
}
}

/* eof */




Theme © iAndrew 2016 - Forum software by © MyBB