4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: hannes2000 on June 30, 2003, 11:31:29 PM

Title: Store arrays as session-variable with "site_sess"-function?
Post by: hannes2000 on June 30, 2003, 11:31:29 PM
Hi.

Is it possible to store whole arrays (maybe even multidimensional arrays (eg. $myarray

TIA and best regards, Hannes
Title: Store arrays as session-variable with "site_sess"-
Post by: Jan on July 01, 2003, 10:32:17 AM
You need to little modifications in includes/sessions.php

In the set_session_var() function, add
Code: [Select]
$value = serialize($value);
after
Code: [Select]
global $site_db;
and in the get_session_var() function
Code: [Select]
$value['sessionvars_value'] = unserialize($value['sessionvars_value']);after
Code: [Select]
if ($value) {
After that you can store all kind of data types.

Jan
Title: Store arrays as session-variable with "site_sess"-
Post by: hannes2000 on July 04, 2003, 04:36:38 PM
Hi Jan.

Thanx, I did the mod but now the variables stored come back as e.g. s:5:"image"; , a variable I stored with

$site_sess->set_session_var("imagemode", $imagemode);

and fetched with

$imagemode = $site_sess->get_session_var("imagemode");

I haven't too much experience with the serialize/unserialize function of PHP, so is this usual? And do I have to extract my variable for my own from the string I got back?

TIA and regards, Hannes