Author Topic: Store arrays as session-variable with "site_sess"-function?  (Read 3215 times)

0 Members and 1 Guest are viewing this topic.

Offline hannes2000

  • Pre-Newbie
  • Posts: 3
    • View Profile
Hi.

Is it possible to store whole arrays (maybe even multidimensional arrays (eg. $myarray [0][1])) with the 4images "site_sess->set_session_var(...)" function/object as session-variables???

TIA and best regards, Hannes

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Store arrays as session-variable with "site_sess"-
« Reply #1 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
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline hannes2000

  • Pre-Newbie
  • Posts: 3
    • View Profile
Store arrays as session-variable with "site_sess"-
« Reply #2 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