1

I've got Cookie Plus and Mo' Variables installed. I'm trying to set, get and increment a value in a cookie. Here's my test script:

{if "{exp:cookie_plus:get name="aa_seq"}" == ""}
{exp:cookie_plus:set name="aa_seq" value="1" seconds="0"}
Setting<br>
{/if}

Cookie: {exp:cookie_plus:get name="aa_seq"}<br>
{exp:cookie_plus:set name="aa_seq" value="<?php echo {exp:cookie_plus:get name="aa_seq"} + 1; ?>" seconds="0"}

I tried it with PHP on input and output, and they both FUBAR.

Would appreciate any pearls of wisdom. Thanks.

1

I'm not sure about the first conditional.. but you could try this for the last line if you want to continue using the add-on. The original last line will fail because you've set it up to need to run cookie_plus both before and after the php increment.

{!-- Set PHP to input --}

{if "{exp:cookie_plus:get name="aa_seq"}" == ""}
    {exp:cookie_plus:set name="aa_seq" value="1" seconds="0"}
    Setting<br>
{/if}

<?php
if(isset($_COOKIE['aa_seq']))
{
    $aa_seq_value = $_COOKIE['aa_seq'] + 1; 
} else {
    echo "No cookie was found."
}
?>

Cookie: {exp:cookie_plus:get name="aa_seq"}<br>
{exp:cookie_plus:set name="aa_seq" value="<?php echo $aa_seq_value; ?>" seconds="0"}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.