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

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
nhaack

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

Post 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
Last edited by nhaack on Thu Dec 25, 2008 6:55 pm, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

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

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
nhaack

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

Post by nhaack »

Hi Calguy,

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

Best
Nils
Post Reply

Return to “The Lounge”