I have a simple page with a simple PayPal Buy button on the page. When a person buys an item, and completes the purchase on PayPal, they will be returned to a thank-you page.

In order to NOT have people access the thank-you page if they have not actually purchased anything, I would like to give every user a unique ID in the return url and use it as a url_segment.

When the user returns, the url will look like www.domain.com/thank-you/34567654
In the template I could do something like:

{if current_id != segment_2}

Does something like this exist?

I know how to pass the option in the PayPal return url, but can one generate a unique user id (session id) and compare it like in my example. Use it as a template var?

1 Answer 1


My approach would be to use Stash.

On the checkout page:

    name="checking_out" {!-- User is checking out --}
    value="1"           {!-- Store any value --}
    scope="user"        {!-- Limit this to the user's session --}
    save="yes"          {!-- Store in the database --}
    refresh="10"        {!-- Only valid for 10 minutes --}

Then check against this being stored on the thank you page:

{if {exp:stash:not_empty name="checking_out" scope="user"}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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