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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.