Where create cookie that holds only user id in Zend MVC project?
I am working with Zend MVC project. MY mission: add cookie that will have only user unique id.
Problem:I don't know where create a cookie.
Options to place create a cookie, that I thing about:
bootstrap.php init()/run()
index.php (not make sense)
In Controllers
My project structure:
application/bootstrap.php
public/index.php
Please help me, if you can give example it will be开发者_开发技巧 great.
Thanks, Yosef
I've put it in the Bootstrup.php, I just created new method called _initUserUniqueId:
protected function _initUserUniqueId(){
$uniq = uniqid();
if(!isset($_COOKIE['f_uniq'])){
setcookie('f_uniq', $uniq, time() + 60 * 60 * 24 * 365, '/');
}
}
精彩评论