Skip to content

Instantly share code, notes, and snippets.

@kpodemski
Created July 8, 2016 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kpodemski/703c9fe2b508fecdd709bf79439e2569 to your computer and use it in GitHub Desktop.
Save kpodemski/703c9fe2b508fecdd709bf79439e2569 to your computer and use it in GitHub Desktop.
Handling guests user in Token::getToken() in PrestaShop
<?php
public static function getToken($page = true, Context $context = null)
{
if (!$context) {
$context = Context::getContext();
}
if (!Validate::isLoadedObject($context->customer)) {
$unique = $context->cookie->id_guest;
} else {
$unique = $context->customer->id.$context->customer->passwd;
}
$unique .= Tools::getRemoteAddr();
if ($page === true) {
return (Tools::encrypt($unique.$_SERVER['SCRIPT_NAME']));
} else {
return (Tools::encrypt($unique.$page));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment