Skip to content

Instantly share code, notes, and snippets.

@Ultimater
Created June 15, 2018 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ultimater/2e72ceaf4ef6eeafedce99abb6eaafc7 to your computer and use it in GitHub Desktop.
Save Ultimater/2e72ceaf4ef6eeafedce99abb6eaafc7 to your computer and use it in GitHub Desktop.
Phalcon trying cookie service anywhere
$di = \Phalcon\Di::getDefault();
echo "<pre><p><hr></p>";
if( isset($di) )
{
echo '<strong>di</strong>: <strong style="color:lime">Found</strong>';
} else {
echo '<strong>di</strong>: <strong style="color:red">Not Found</strong>';
}
echo '<br>';
if( $di->has('cookies') )
{
echo '<strong>Cookies</strong> service: <strong style="color:lime">Found</strong>';
} else {
echo '<strong>Cookies</strong> servoce: <strong style="color:red">Not Found</strong>';
}
echo '<br>';
try{
$di->getCookies()->set('blah-key','blah-value');
echo '<strong style="color:lime">Successfully set a cookie</strong>';
}catch(\Exception $e){
echo '<strong style="color:red">Failed to set a cookie</strong><br>';
echo $e->getMessage();
}catch(\Throwable $e){
echo '<strong style="color:red">Failed to set a cookie</strong><br>';
echo $e->getMessage();
}
echo "<p><hr></p></pre>";
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment