es_cookie.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class es_cookie
  10. {
  11. // 判断Cookie是否存在
  12. static function is_set($name) {
  13. return isset($_COOKIE[$name]);
  14. }
  15. // 获取某个Cookie值
  16. static function get($name) {
  17. if(isset($_COOKIE[$name]))
  18. $value = $_COOKIE[$name];
  19. else
  20. $value = null;
  21. return $value;
  22. }
  23. // 设置某个Cookie值
  24. static function set($name,$value,$expire='',$path='',$domain='') {
  25. $path = $GLOBALS['distribution_cfg']['COOKIE_PATH'];
  26. $domain = $GLOBALS['distribution_cfg']['DOMAIN_ROOT'];
  27. $expire = !empty($expire)?get_gmtime()+$expire:0;
  28. setcookie($name, $value,$expire,$path,$domain);
  29. }
  30. // 删除某个Cookie值
  31. static function delete($name) {
  32. es_cookie::set($name,'',0);
  33. }
  34. // 清空Cookie值
  35. static function clear() {
  36. unset($_COOKIE);
  37. }
  38. }
  39. ?>