Jump to content

assigning a variable to a $_SESSION


dcjones

Recommended Posts

Hi all

 

I have a script which produces random codes used for coupons.

 

The script that generates the random code is:

 

function generate_coupons(){

    global $db, $t, $vars;

    $vars['discount'] = trim("$vars[discount_v] $vars[discount_t]");

   

    set_date_from_smarty('begin_date', $vars);

    set_date_from_smarty('expire_date', $vars);

    $batch_id = $db->generate_coupons($vars);

    $coupons = $db->get_coupons('batch_id', $batch_id);

    $t->assign('coupons', $coupons);

$t->display('coupon_generated_tier.php');

}

 

On my SMARTY template script I have:

 

input type="text" readonly="readonly" class="agentformbl" name="couponid" value="{foreach from=$coupons item=c}

{$c.code}

{/foreach}" size="32" />

 

What I am trying to do is assign the content of "{foreach from=$coupons item=c}{$c.code}{/foreach} to a $_SESSION variable.

 

Hers a very bad example:

 

$_SESSION['c'] = {foreach from=$coupons item=c}{$c.code}{/foreach}

 

I know that thos example is not the way it is done, but I just don't know how.

 

Can anyone please help.

 

Best regards

 

dereck

 

Link to comment
https://forums.phpfreaks.com/topic/80696-assigning-a-variable-to-a-_session/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.