php7.0 SessionUpdateTimestampHandlerInterface接口实现功能

来源:互联网 发布:琼州海峡隧道 知乎 编辑:程序博客网 时间:2024/05/29 19:29

文章来源:http://blog.csdn.net/qq_26656329/article/details/78733583

这是一个抽象接口,是php7.0新增的,然而官方没有这个接口的说明。但是源码里面的确是有这个接口https://github.com/php/php-src/blob/PHP-7.0.25/ext/session/session.c#L2616-L2623SessionUpdateTimestampHandlerInterfacestatic const zend_function_entry php_session_update_timestamp_iface_functions[] = {    PHP_ABSTRACT_ME(SessionUpdateTimestampHandlerInterface, validateId, arginfo_session_class_validateId)    PHP_ABSTRACT_ME(SessionUpdateTimestampHandlerInterface, updateTimestamp, arginfo_session_class_updateTimestamp)    { NULL, NULL, NULL }};这个接口只有两个方法validateId:检查session会话id是否存在当手动设置id的话这个方法还是有用的,public function validateId(string $key) : bool;updateTimestamp:更新session时间戳public function updateTimestamp(string $key, string $val) : bool;<?phpinterface SessionUpdateTimestampHandlerInterface{    /**     * Checks if a session identifier already exists or not.     *     * @param string $key     *     * @return bool     */    public function validateId($key);    /**     * Updates the timestamp of a session when its data didn't change.     *     * @param string $key     * @param string $val     *     * @return bool     */    public function updateTimestamp($key, $val);}

参考例子
一个鲜为人知的接口!!!!!

原创粉丝点击