Jump to content

What is " var static_token" and "var token"


Recommended Posts

Hi guys,

 

I am trying to figure out what these do in PrestaShop?

 

var static_token = '{$static_token}';

var token = '{$token}';

 

They are found in /theme/header.tpl in the <head> code, and then the token also gets

populated in the <form> for the add-to-cart button...

 

Does anyone know what these are or what they do? Can I make them STATIC, and if so,

will it effect anything in my shop?

 

Reason for that, is this:

https://www.prestashop.com/forums/topic/555525-how-to-create-static-product-pages-without-token/

 

 

thanks!
 
Elyssa
Link to comment
Share on other sites

For security reason PrestaShop generate MD5 hashed token which is appended to each AJAX call URL to make sure that the request comes by human activity and not by a boat. Both token are created by PrestaShop and we need to use it in our code too, so what code you mentioned is declare variable in JavaScript and assign value of token and static token to those JavaScrip variable. After that we have both token value in JavaScript variable and we can use it in our code. When we made any AJAX call, token will be compared against the token which is stored in cookie/session to make sure there is not any malicious activity by that particular AJAX call.

  • Like 1
Link to comment
Share on other sites

i *sort* of understand what you are saying... i'm not a programmer though hehe..

 

so, my question is... if i populate the token codes in the header.tpl, and I use the same tokens 

on the static product pages I make, will that work?

 

So basically, ALL customers would use that token...

 

will the cart work?

 

Thanks!

 

Elyssa

Link to comment
Share on other sites

ok thanks.. as of now on the website, I have put a value in each of $token and $static_token, so all the 

pages call the same tokens... however, upon testing the page, it sometimes does NOT add the product 

to the shopping cart... sometimes i will just go directly to this page:

 

www.allo.com/shop/

 

sometimes it will show cart page (which shows as blank page for some reason)

 

Are you able to test this page, and see if you can add-to-cart without issues?

 

http://www.allo.com/sparky/sparky-sbc.html

 

Please tell me your results...

 

I tried from my cell phone at an airport, and still, I got this page:

www.allo.com/shop/

 

but sometimes I get the summary page, like with URL like this

https://www.allo.com/shop/order?ipa=43

 

i cannot figure out why :(

 

if no one can buy anything, i will have huge problems with my boss! lol

 

Thanks for your help!

 

Elyssa

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...