Page 1 of 1

[solved] Store Session-Data for regular Visitors with CMSMS. Need directions.

Posted: Thu Dec 25, 2008 5:38 pm
by nhaack
Hi there,

I have a problem that I do not really know how to approach.

Following Scenario:
A user opens a page in CMSMS that contains information generated by a plug-in. The users are not registered front end users or something - just "regular" visitors. Now I want to store parts of this data (string-data, defined number of fields) somehow - so that when the user accesses another page, I can reuse the data stored to adjust the other pages content (use the stored data as parameters for plug-ins).

So I need to have the data available from within the templates.

TEMPLATE A -> PLUG-in A -> GENERATED DATA -> TEMPLATE B,C,D... ->PLUG-in B

I used to do this by transferring the data via the URL, but I would prefer a handling which allows me to set a cookie or do it all server-sided (preferred).

Does CMSMS have such abilities already or is there a module I could use?

Mhh... I just thought that I could probably use one of the shopping carts modules. If they require logged in users, probably I can "fake" users with kind of a random string/number. What do you think? Does someone has more experience and can point me into a direction? What commands should I look at? Have a good site or tutorial that explains it very brief and holds some code examples? No detailed description needed (however, I wouldn't mind ;D), I just don't really know where to start in this topic.

Thanks and Best regards
Nils

Re: Store Session-Data for regular Visitors with CMSMS. Need directions.

Posted: Thu Dec 25, 2008 5:47 pm
by calguy1000
Just write a UDT to store things in the session
then you can extract them with $smarty.session.myvariable.

i.e (untested).... create a udt called session_set that looks something like this.

Code: Select all

if( isset($params['var'])
{
  $var = trim($params['var']);
  if( isset($params['value']) )
     {
        $_SESSION[$var] = $params['value'];
     }
 else
     {
        @unset($_SESSION[$var]); 
     }
}
You call it like {session_set var='test' value='123'}
You extract the value with {$smarty.session.test} on any page.

They'll be in the session till the user closes the browser window, or you delete them.

Re: Store Session-Data for regular Visitors with CMSMS. Need directions.

Posted: Thu Dec 25, 2008 6:55 pm
by nhaack
Hi Calguy,

It's easier than I thought. Thanks a lot for the hint :)

Best
Nils