开发者

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:

  1. bootstrap.php init()/run()

  2. index.php (not make sense)

  3. 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, '/');
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜