Reputation: 535
how to access prestashop cookie?
the directory structure islike this
/
|
|-index.php
|
|-prestashop/
|
|-(presta shop files)
I manage to do a login from the index.php.
but i cannot access the cookie to check if the user logged in or not.
any way to check it or get the user name
Upvotes: 0
Views: 2187
Reputation: 183
For Prestashop 1.6 its different now, there is no $smarty
and no $cookie
, all in Context.
How to access the Context?
From inside a Controller subclass, an AdminTab subclass or a Module subclass, the Context should be called with this shortcut: $this->context
.
From anywhere else, you can get the Context
instance by calling Context::getContext()
.
Old way
$cookie->id_lang;
New way
$this->context->language->id;
More about this in docs here http://doc.prestashop.com/display/PS16/Using+the+Context+Object#UsingtheContextObject-WhatistheContextobject?
Upvotes: 1
Reputation: 1145
Prestashop maintains a global $cookie variable which is an object of type Cookie
. As long as you're bootstrapping Prestashop in your external index.php file, then you should be able to access it:
function myfunction()
{
global $cookie;
if ($cookie->isLogged)
echo 'Here be dragons.';
}
Without knowing how you're accessing the Prestashop core to perform the login though it's hard to give specific advice...
Upvotes: 0