Created
June 15, 2018 02:50
-
-
Save Ultimater/2e72ceaf4ef6eeafedce99abb6eaafc7 to your computer and use it in GitHub Desktop.
Phalcon trying cookie service anywhere
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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