Categories > TinyButStrong general >

TBS detroys SESSION vars ?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: manuel
Date: 2004-02-03
Time: 12:44

TBS detroys SESSION vars ?

Hi,

it seems that TBS destroy my session vars, i use the following code:

if (!isset($_SESSION['dbasket'])) $dbasket = &new basket();
        else $dbasket=unserialize($_SESSION['dbasket']);

$dbasket->show();
.....

$_SESSION['dbasket'] = serialize($dbasket);

This worked fine all the time i have my basket session in place.

But if i use TBS (especially on calling the the TBS->show() function) the basket Session became destroyed.

Any Ideas ?

greetings

Manuel
By: Skrol29
Date: 2004-02-03
Time: 15:00

Re: TBS detroys SESSION vars ?

Hi manuel,

I don't undersant the line
  $dbasket = &new basket();
Is that supposed to be a TBS object ?

I've also read in the PHP manual for objects variables, only properties are serialized, not methods. There is maybe a point here.
By: manuel
Date: 2004-02-04
Time: 12:21

Re: TBS detroys SESSION vars ?

Hi Skrol,

$dbasket = &new basket();
is a aclass of my own.

You are right that only properties will be serialized, but when you unserialize it and have the class description included before, the object will be instantiated with the the properties from the unserialized session (in my case) and you can use the object in every script you like.

Like i said before this mechanism of serializing objects worked fine until the point the TBS Object got involved.

I have done a test with a string in a session with the same behaviour -> The session do not wokr right with a TBS Object in the script.
By: Skrol29
Date: 2004-02-05
Time: 00:28

Re: TBS detroys SESSION vars ?

By default, $dbasket->Show() ends the script.

Do you really need the serilize/unserialize?
$_SESSION is already supposed to to that.
By: manuel
Date: 2004-02-05
Time: 11:38

Re: TBS detroys SESSION vars ?

Success !

Reading the manual can sometimes be a great advantage !

Yes, i have to serialize, because i want to store changes inside the object at the end of the page, my fault was that $TBS->show() quits the script. Now i use the TBS_SHOW constant on the render property, and everything works fine.

thanks for your ideas !
By: Skrol29
Date: 2004-02-05
Time: 11:49

Re: TBS detroys SESSION vars ?

> Yes, i have to serialize

I don't work with session often, but the PHP manual says that all variables stored in $_SESSION are automatically serialized to be saved betweens user sessions.