Guest User

Untitled

a guest
Dec 12th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. $inputCookie = JFactory::getApplication()->input->cookie;
  2. $value = $inputCookie->get($name = 'myCookie', $defaultValue = null);
  3. $cookieExists = ($value !== null);
  4. $inputCookie->set($name = 'myCookie', $value = '123', $expire = 0);
  5.  
  6. $app = JFactory::getApplication();
  7.  
  8. // Get the cookie
  9. $value = $app->input->cookie->get('myCookie', null);
  10.  
  11. // If there's no cookie value, manually set it
  12. if ($value == null)
  13. {
  14. $value = HOWEVER YOU GET THE CART DATA
  15. }
  16.  
  17. // Set the cookie
  18. $time = time() + 604800; // 1 week
  19. $app->input->cookie->set('myCookie', $value, $time, $app->get('cookie_path', '/'), $app->get('cookie_domain'), $app->isSSLConnection());
  20.  
  21. JRequest::setVar($var, $value, 'cookie');
  22. JRequest::getString($var, $default, 'cookie')
Add Comment
Please, Sign In to add comment