Welcome Guest, Not a member yet? Register   Sign In
Session Class and Variable Type
#1

[eluser]CMCDragonkai[/eluser]
I've noticed that when retrieving session variables, it doesn't keep the the type of the variable that was originally saved.

I suppose this has something to do with the fact that I have it saved in the database.

Is there a workaround this? Maybe like saving the type of the variable in the database aswell.
#2

[eluser]Cristian Gilè[/eluser]
Hi CMCDragonkai,

session class in database keeps data and relative type. If you take a look in the session table, the field user_data contains something like this:

Code:
"session_name";i:1;

where session_name is the name of one of your session vars, and in this case, i:1 is an integer value (1).

i stands for integer, b for boolean and s for string.


Cristian Gilè
#3

[eluser]CMCDragonkai[/eluser]
Really, how come when I try to access my session variable through userdata and then vardump it, what was previously an integer becomes a string?
#4

[eluser]Cristian Gilè[/eluser]
Please, provide the code.
#5

[eluser]InsiteFX[/eluser]
Thats because the session user_data is serialized!

You need to un-serialize it if you want to look at the
varialbles alone.

InsiteFX
#6

[eluser]stormbytes[/eluser]
I'm having a similar problem trying to store an object in the session and then retrieve that object (assigning it to a variable) and use it as I would any instance of that class. Tried serialize/unserialize, getting errors... ughh!
#7

[eluser]CMCDragonkai[/eluser]
[quote author="InsiteFX" date="1294541211"]Thats because the session user_data is serialized!

You need to un-serialize it if you want to look at the
varialbles alone.

InsiteFX[/quote]

Could you provide an example?




Theme © iAndrew 2016 - Forum software by © MyBB