SOLVED: Generate session in UDT, possible ?

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
eus
Forum Members
Forum Members
Posts: 40
Joined: Fri Jan 16, 2009 12:56 pm

SOLVED: Generate session in UDT, possible ?

Post by eus »

Hello,

For a specific project i need a session in an udt. In this specific example i can't use frontendusers or other core packages.

So session_start() and assigning value's in the udt does not work like in native php. De variables are empty.

Should i store the session in global $gCms for example ?

Anyone experience with a custom session in a udt tag ?


Thnx
Last edited by eus on Fri Jun 17, 2011 7:08 am, edited 1 time in total.
psy
Power Poster
Power Poster
Posts: 463
Joined: Sat Jan 22, 2005 11:19 am

Re: Generate session in UDT, possible ?

Post by psy »

In my limited php experience, session vars whether created in the content or via a UDT, dont take effect until the page is refreshed/redirected.

Is your session var called after a redirect?
vinyl
Forum Members
Forum Members
Posts: 149
Joined: Mon Jul 13, 2009 8:18 pm

Re: Generate session in UDT, possible ?

Post by vinyl »

What code are you using exactly and where do you place it?

You can pass variables to a UDT and use that in a session, even from a module etc..

For example:

A sample UDT called "session":

Code: Select all

session_start();
$_SESSION['yoursession'] = $params['yourinput'];
echo $_SESSION['yoursession'];
The content on my page (here we capture the page title and pass it to our UDT,but that could be any module):

Code: Select all

{capture assign='test'}
{title}
{/capture}
{session yourinput=$test}
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: Generate session in UDT, possible ?

Post by Jos »

Don't know if it helps, but you don't necessarily need a UDT to display the value of a session. It can be done with Smarty directly

Code: Select all

{* display the php session variable "id" ($_SESSION['id']) *}
{$smarty.session.id}
http://www.smarty.net/docsv2/en/languag ... ty.request
eus
Forum Members
Forum Members
Posts: 40
Joined: Fri Jan 16, 2009 12:56 pm

Generate session in UDT, possible ?

Post by eus »

Hello,

Thanx for the suggestions. I've solved it by doing this in an UDT.

@session_regenerate_id() ;
$session=session_id() ;

It looks like session_start was already loaded in the cms
Post Reply

Return to “The Lounge”