11e3a9652a first 8 anos atrás escape.js 11e3a9652a first 8 anos atrás escapeRegExp.js 11e3a9652a first 8 anos atrás every.js 11e3a9652a first 8 anos atrás extend.js 11e3a9652a first 8 anos atrás extendAll.js 11e3a9652a first 8 anos atrás extendAllWith.js 11e3a9652a first 8 anos atrás extendWith.js 11e3a9652a first 8 anos atrás fill.js 11e3a9652a first 8 anos atrás filter.js 11e3a9652a first 8 anos atrás find.js 11e3a9652a first 8 anos atrás findFrom.js 11e3a9652a first 8 anos atrás findIndex.js 11e3a9652a first 8 anos atrás findIndexFrom.js 11e3a9652a first 8 anos atrás findKey.js 11e3a9652a first 8 anos atrás findLast.js 11e3a9652a first 8 anos atrás findLastFrom.js 11e3a9652a first 8 anos atrás findLastIndex.js 11e3a9652a first 8 anos atrás findLastIndexFrom.js 11e3a9652a first 8 anos atrás findLastKey.js 11e3a9652a first 8 anos atrás first.js 11e3a9652a first 8 anos atrás flatMap.js 11e3a9652a first 8 anos atrás flatMapDeep.js 11e3a9652a first 8 anos atrás flatMapDepth.js 11e3a9652a first 8 anos atrás flatten.js 11e3a9652a first 8 anos atrás flattenDeep.js 11e3a9652a first 8 anos atrás flattenDepth.js 11e3a9652a first 8 anos atrás flip.js 11e3a9652a first 8 anos atrás floor.js 11e3a9652a first 8 anos atrás flow.js 11e3a9652a first 8 anos atrás flowRight.js 11e3a9652a first 8 anos atrás forEach.js 11e3a9652a first 8 anos atrás forEachRight.js 11e3a9652a first 8 anos atrás forIn.js 11e3a9652a first 8 anos atrás forInRight.js 11e3a9652a first 8 anos atrás forOwn.js 11e3a9652a first 8 anos atrás forOwnRight.js 11e3a9652a first 8 anos atrás fromPairs.js 11e3a9652a first 8 anos atrás function.js 11e3a9652a first 8 anos atrás functions.js 11e3a9652a first 8 anos atrás functionsIn.js 11e3a9652a first 8 anos atrás get.js 11e3a9652a first 8 anos atrás getOr.js 11e3a9652a first 8 anos atrás groupBy.js 11e3a9652a first 8 anos atrás gt.js 11e3a9652a first 8 anos atrás gte.js 11e3a9652a first 8 anos atrás has.js 11e3a9652a first 8 anos atrás hasIn.js 11e3a9652a first 8 anos atrás head.js 11e3a9652a first 8 anos atrás identical.js 11e3a9652a first 8 anos atrás identity.js 11e3a9652a first 8 anos atrás inRange.js 11e3a9652a first 8 anos atrás includes.js 11e3a9652a first 8 anos atrás includesFrom.js 11e3a9652a first 8 anos atrás indexBy.js 11e3a9652a first 8 anos atrás indexOf.js 11e3a9652a first 8 anos atrás indexOfFrom.js 11e3a9652a first 8 anos atrás init.js 11e3a9652a first 8 anos atrás initial.js 11e3a9652a first 8 anos atrás intersection.js 11e3a9652a first 8 anos atrás intersectionBy.js 11e3a9652a first 8 anos atrás intersectionWith.js 11e3a9652a first 8 anos atrás invert.js 11e3a9652a first 8 anos atrás invertBy.js 11e3a9652a first 8 anos atrás invertObj.js 11e3a9652a first 8 anos atrás invoke.js 11e3a9652a first 8 anos atrás invokeArgs.js 11e3a9652a first 8 anos atrás invokeArgsMap.js 11e3a9652a first 8 anos atrás invokeMap.js 11e3a9652a first 8 anos atrás isArguments.js 11e3a9652a first 8 anos atrás isArray.js 11e3a9652a first 8 anos atrás isArrayBuffer.js 11e3a9652a first 8 anos atrás isArrayLike.js 11e3a9652a first 8 anos atrás isArrayLikeObject.js 11e3a9652a first 8 anos atrás isBoolean.js 11e3a9652a first 8 anos atrás isBuffer.js 11e3a9652a first 8 anos atrás isDate.js 11e3a9652a first 8 anos atrás isElement.js 11e3a9652a first 8 anos atrás isEmpty.js 11e3a9652a first 8 anos atrás isEqual.js 11e3a9652a first 8 anos atrás isEqualWith.js 11e3a9652a first 8 anos atrás isError.js 11e3a9652a first 8 anos atrás isFinite.js 11e3a9652a first 8 anos atrás isFunction.js 11e3a9652a first 8 anos atrás isInteger.js 11e3a9652a first 8 anos atrás isLength.js 11e3a9652a first 8 anos atrás isMap.js 11e3a9652a first 8 anos atrás isMatch.js 11e3a9652a first 8 anos atrás isMatchWith.js 11e3a9652a first 8 anos atrás isNaN.js 11e3a9652a first 8 anos atrás isNative.js 11e3a9652a first 8 anos atrás isNil.js 11e3a9652a first 8 anos atrás isNull.js 11e3a9652a first 8 anos atrás isNumber.js 11e3a9652a first 8 anos atrás isObject.js 11e3a9652a first 8 anos atrás isObjectLike.js 11e3a9652a first 8 anos atrás isPlainObject.js 11e3a9652a first 8 anos atrás isRegExp.js 11e3a9652a first 8 anos atrás isSafeInteger.js 11e3a9652a first 8 anos atrás isSet.js 11e3a9652a first 8 anos atrás isString.js 11e3a9652a first 8 anos atrás isSymbol.js 11e3a9652a first 8 anos atrás isTypedArray.js 11e3a9652a first 8 anos atrás isUndefined.js 11e3a9652a first 8 anos atrás isWeakMap.js 11e3a9652a first 8 anos atrás isWeakSet.js 11e3a9652a first 8 anos atrás iteratee.js 11e3a9652a first 8 anos atrás join.js 11e3a9652a first 8 anos atrás juxt.js 11e3a9652a first 8 anos atrás kebabCase.js 11e3a9652a first 8 anos atrás keyBy.js 11e3a9652a first 8 anos atrás keys.js 11e3a9652a first 8 anos atrás keysIn.js 11e3a9652a first 8 anos atrás lang.js 11e3a9652a first 8 anos atrás last.js 11e3a9652a first 8 anos atrás lastIndexOf.js 11e3a9652a first 8 anos atrás lastIndexOfFrom.js 11e3a9652a first 8 anos atrás lowerCase.js 11e3a9652a first 8 anos atrás lowerFirst.js 11e3a9652a first 8 anos atrás lt.js 11e3a9652a first 8 anos atrás lte.js 11e3a9652a first 8 anos atrás map.js 11e3a9652a first 8 anos atrás mapKeys.js 11e3a9652a first 8 anos atrás mapValues.js 11e3a9652a first 8 anos atrás matches.js 11e3a9652a first 8 anos atrás matchesProperty.js 11e3a9652a first 8 anos atrás math.js 11e3a9652a first 8 anos atrás max.js 11e3a9652a first 8 anos atrás maxBy.js 11e3a9652a first 8 anos atrás mean.js 11e3a9652a first 8 anos atrás meanBy.js 11e3a9652a first 8 anos atrás memoize.js 11e3a9652a first 8 anos atrás merge.js 11e3a9652a first 8 anos atrás mergeAll.js 11e3a9652a first 8 anos atrás mergeAllWith.js 11e3a9652a first 8 anos atrás mergeWith.js 11e3a9652a first 8 anos atrás method.js 11e3a9652a first 8 anos atrás methodOf.js 11e3a9652a first 8 anos atrás min.js 11e3a9652a first 8 anos atrás minBy.js 11e3a9652a first 8 anos atrás mixin.js 11e3a9652a first 8 anos atrás multiply.js 11e3a9652a first 8 anos atrás nAry.js 11e3a9652a first 8 anos atrás negate.js 11e3a9652a first 8 anos atrás next.js 11e3a9652a first 8 anos atrás noop.js 11e3a9652a first 8 anos atrás now.js 11e3a9652a first 8 anos atrás nth.js 11e3a9652a first 8 anos atrás nthArg.js 11e3a9652a first 8 anos atrás number.js 11e3a9652a first 8 anos atrás object.js 11e3a9652a first 8 anos atrás omit.js 11e3a9652a first 8 anos atrás omitAll.js 11e3a9652a first 8 anos atrás omitBy.js 11e3a9652a first 8 anos atrás once.js 11e3a9652a first 8 anos atrás orderBy.js 11e3a9652a first 8 anos atrás over.js 11e3a9652a first 8 anos atrás overArgs.js 11e3a9652a first 8 anos atrás overEvery.js 11e3a9652a first 8 anos atrás overSome.js 11e3a9652a first 8 anos atrás pad.js 11e3a9652a first 8 anos atrás padChars.js 11e3a9652a first 8 anos atrás padCharsEnd.js 11e3a9652a first 8 anos atrás padCharsStart.js 11e3a9652a first 8 anos atrás padEnd.js 11e3a9652a first 8 anos atrás padStart.js 11e3a9652a first 8 anos atrás parseInt.js 11e3a9652a first 8 anos atrás partial.js 11e3a9652a first 8 anos atrás partialRight.js 11e3a9652a first 8 anos atrás partition.js 11e3a9652a first 8 anos atrás path.js 11e3a9652a first 8 anos atrás pathEq.js 11e3a9652a first 8 anos atrás pathOr.js 11e3a9652a first 8 anos atrás paths.js 11e3a9652a first 8 anos atrás pick.js 11e3a9652a first 8 anos atrás pickAll.js 11e3a9652a first 8 anos atrás pickBy.js 11e3a9652a first 8 anos atrás pipe.js 11e3a9652a first 8 anos atrás placeholder.js 11e3a9652a first 8 anos atrás plant.js 11e3a9652a first 8 anos atrás pluck.js 11e3a9652a first 8 anos atrás prop.js 11e3a9652a first 8 anos atrás propEq.js 11e3a9652a first 8 anos atrás propOr.js 11e3a9652a first 8 anos atrás property.js 11e3a9652a first 8 anos atrás propertyOf.js 11e3a9652a first 8 anos atrás props.js 11e3a9652a first 8 anos atrás pull.js 11e3a9652a first 8 anos atrás pullAll.js 11e3a9652a first 8 anos atrás pullAllBy.js 11e3a9652a first 8 anos atrás pullAllWith.js 11e3a9652a first 8 anos atrás pullAt.js 11e3a9652a first 8 anos atrás random.js 11e3a9652a first 8 anos atrás range.js 11e3a9652a first 8 anos atrás rangeRight.js 11e3a9652a first 8 anos atrás rangeStep.js 11e3a9652a first 8 anos atrás rangeStepRight.js 11e3a9652a first 8 anos atrás rearg.js 11e3a9652a first 8 anos atrás reduce.js 11e3a9652a first 8 anos atrás reduceRight.js 11e3a9652a first 8 anos atrás reject.js 11e3a9652a first 8 anos atrás remove.js 11e3a9652a first 8 anos atrás repeat.js 11e3a9652a first 8 anos atrás replace.js 11e3a9652a first 8 anos atrás rest.js 11e3a9652a first 8 anos atrás restFrom.js 11e3a9652a first 8 anos atrás result.js 11e3a9652a first 8 anos atrás reverse.js 11e3a9652a first 8 anos atrás round.js 11e3a9652a first 8 anos atrás sample.js 11e3a9652a first 8 anos atrás sampleSize.js 11e3a9652a first 8 anos atrás seq.js 11e3a9652a first 8 anos atrás set.js 11e3a9652a first 8 anos atrás setWith.js 11e3a9652a first 8 anos atrás shuffle.js 11e3a9652a first 8 anos atrás size.js 11e3a9652a first 8 anos atrás slice.js 11e3a9652a first 8 anos atrás snakeCase.js 11e3a9652a first 8 anos atrás some.js 11e3a9652a first 8 anos atrás sortBy.js 11e3a9652a first 8 anos atrás sortedIndex.js 11e3a9652a first 8 anos atrás sortedIndexBy.js 11e3a9652a first 8 anos atrás sortedIndexOf.js 11e3a9652a first 8 anos atrás sortedLastIndex.js 11e3a9652a first 8 anos atrás sortedLastIndexBy.js 11e3a9652a first 8 anos atrás sortedLastIndexOf.js 11e3a9652a first 8 anos atrás sortedUniq.js 11e3a9652a first 8 anos atrás sortedUniqBy.js 11e3a9652a first 8 anos atrás split.js 11e3a9652a first 8 anos atrás spread.js 11e3a9652a first 8 anos atrás spreadFrom.js 11e3a9652a first 8 anos atrás startCase.js 11e3a9652a first 8 anos atrás startsWith.js 11e3a9652a first 8 anos atrás string.js 11e3a9652a first 8 anos atrás stubArray.js 11e3a9652a first 8 anos atrás stubFalse.js 11e3a9652a first 8 anos atrás stubObject.js 11e3a9652a first 8 anos atrás stubString.js 11e3a9652a first 8 anos atrás stubTrue.js 11e3a9652a first 8 anos atrás subtract.js 11e3a9652a first 8 anos atrás sum.js 11e3a9652a first 8 anos atrás sumBy.js 11e3a9652a first 8 anos atrás symmetricDifference.js 11e3a9652a first 8 anos atrás symmetricDifferenceBy.js 11e3a9652a first 8 anos atrás symmetricDifferenceWith.js 11e3a9652a first 8 anos atrás tail.js 11e3a9652a first 8 anos atrás take.js 11e3a9652a first 8 anos atrás takeLast.js 11e3a9652a first 8 anos atrás takeLastWhile.js 11e3a9652a first 8 anos atrás takeRight.js 11e3a9652a first 8 anos atrás takeRightWhile.js 11e3a9652a first 8 anos atrás takeWhile.js 11e3a9652a first 8 anos atrás tap.js 11e3a9652a first 8 anos atrás template.js 11e3a9652a first 8 anos atrás templateSettings.js 11e3a9652a first 8 anos atrás throttle.js 11e3a9652a first 8 anos atrás thru.js 11e3a9652a first 8 anos atrás times.js 11e3a9652a first 8 anos atrás toArray.js 11e3a9652a first 8 anos atrás toFinite.js 11e3a9652a first 8 anos atrás toInteger.js 11e3a9652a first 8 anos atrás toIterator.js 11e3a9652a first 8 anos atrás toJSON.js 11e3a9652a first 8 anos atrás toLength.js 11e3a9652a first 8 anos atrás toLower.js 11e3a9652a first 8 anos atrás toNumber.js 11e3a9652a first 8 anos atrás toPairs.js 11e3a9652a first 8 anos atrás toPairsIn.js 11e3a9652a first 8 anos atrás toPath.js 11e3a9652a first 8 anos atrás toPlainObject.js 11e3a9652a first 8 anos atrás toSafeInteger.js 11e3a9652a first 8 anos atrás toString.js 11e3a9652a first 8 anos atrás toUpper.js 11e3a9652a first 8 anos atrás transform.js 11e3a9652a first 8 anos atrás trim.js 11e3a9652a first 8 anos atrás trimChars.js 11e3a9652a first 8 anos atrás trimCharsEnd.js 11e3a9652a first 8 anos atrás trimCharsStart.js 11e3a9652a first 8 anos atrás trimEnd.js 11e3a9652a first 8 anos atrás trimStart.js 11e3a9652a first 8 anos atrás truncate.js 11e3a9652a first 8 anos atrás unapply.js 11e3a9652a first 8 anos atrás unary.js 11e3a9652a first 8 anos atrás unescape.js 11e3a9652a first 8 anos atrás union.js 11e3a9652a first 8 anos atrás unionBy.js 11e3a9652a first 8 anos atrás unionWith.js 11e3a9652a first 8 anos atrás uniq.js 11e3a9652a first 8 anos atrás uniqBy.js 11e3a9652a first 8 anos atrás uniqWith.js 11e3a9652a first 8 anos atrás uniqueId.js 11e3a9652a first 8 anos atrás unnest.js 11e3a9652a first 8 anos atrás unset.js 11e3a9652a first 8 anos atrás unzip.js 11e3a9652a first 8 anos atrás unzipWith.js 11e3a9652a first 8 anos atrás update.js 11e3a9652a first 8 anos atrás updateWith.js 11e3a9652a first 8 anos atrás upperCase.js 11e3a9652a first 8 anos atrás upperFirst.js 11e3a9652a first 8 anos atrás useWith.js 11e3a9652a first 8 anos atrás util.js 11e3a9652a first 8 anos atrás value.js 11e3a9652a first 8 anos atrás valueOf.js 11e3a9652a first 8 anos atrás values.js 11e3a9652a first 8 anos atrás valuesIn.js 11e3a9652a first 8 anos atrás where.js 11e3a9652a first 8 anos atrás whereEq.js 11e3a9652a first 8 anos atrás without.js 11e3a9652a first 8 anos atrás words.js 11e3a9652a first 8 anos atrás wrap.js 11e3a9652a first 8 anos atrás wrapperAt.js 11e3a9652a first 8 anos atrás wrapperChain.js 11e3a9652a first 8 anos atrás wrapperLodash.js 11e3a9652a first 8 anos atrás wrapperReverse.js 11e3a9652a first 8 anos atrás wrapperValue.js 11e3a9652a first 8 anos atrás xor.js 11e3a9652a first 8 anos atrás xorBy.js 11e3a9652a first 8 anos atrás xorWith.js 11e3a9652a first 8 anos atrás zip.js 11e3a9652a first 8 anos atrás zipAll.js 11e3a9652a first 8 anos atrás zipObj.js 11e3a9652a first 8 anos atrás zipObject.js 11e3a9652a first 8 anos atrás zipObjectDeep.js 11e3a9652a first 8 anos atrás zipWith.js 11e3a9652a first 8 anos atrás tamron - Gogs: Go Git Service

Nessuna descrizione

Session.class.php 23KB

    <?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK IT ] // +---------------------------------------------------------------------- // | Copyright (c) 2006-2012 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st <liu21st@gmail.com> // +---------------------------------------------------------------------- // $Id: Session.class.php 2702 2012-02-02 12:35:01Z liu21st $ define("HTTP_SESSION_STARTED", 1); define("HTTP_SESSION_CONTINUED", 2); /** +------------------------------------------------------------------------------ * Session管理类 +------------------------------------------------------------------------------ * @category Think * @package Think * @subpackage Util * @author liu21st <liu21st@gmail.com> * @version $Id: Session.class.php 2702 2012-02-02 12:35:01Z liu21st $ +------------------------------------------------------------------------------ */ class Session { /** +---------------------------------------------------------- * 启动Session +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ static function start() { session_start(); if (!isset($_SESSION['__HTTP_Session_Info'])) { $_SESSION['__HTTP_Session_Info'] = HTTP_SESSION_STARTED; } else { $_SESSION['__HTTP_Session_Info'] = HTTP_SESSION_CONTINUED; } Session::setExpire(C('SESSION_EXPIRE')); } /** +---------------------------------------------------------- * 暂停Session +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ static function pause() { session_write_close(); } /** +---------------------------------------------------------- * 清空Session +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ static function clearLocal() { $local = Session::localName(); unset($_SESSION[$local]); } /** +---------------------------------------------------------- * 清空Session +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ static function clear() { $_SESSION = array(); } /** +---------------------------------------------------------- * 销毁Session +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ static function destroy() { unset($_SESSION); session_destroy(); } /** +---------------------------------------------------------- * 检测SessionID +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ static function detectID() { if(session_id()!='') { return session_id(); } if (Session::useCookies()) { if (isset($_COOKIE[Session::name()])) { return $_COOKIE[Session::name()]; } } else { if (isset($_GET[Session::name()])) { return $_GET[Session::name()]; } if (isset($_POST[Session::name()])) { return $_POST[Session::name()]; } } return null; } /** +---------------------------------------------------------- * 设置或者获取当前Session name +---------------------------------------------------------- * @param string $name session名称 +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return string 返回之前的Session name +---------------------------------------------------------- */ static function name($name = null) { return isset($name) ? session_name($name) : session_name(); } /** +---------------------------------------------------------- * 设置或者获取当前SessionID +---------------------------------------------------------- * @param string $id sessionID +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return void 返回之前的sessionID +---------------------------------------------------------- */ static function id($id = null) { return isset($id) ? session_id($id) : session_id(); } /** +---------------------------------------------------------- * 设置或者获取当前Session保存路径 +---------------------------------------------------------- * @param string $path 保存路径名 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ static function path($path = null) { return !empty($path)? session_save_path($path):session_save_path(); } /** +---------------------------------------------------------- * 设置Session 过期时间 +---------------------------------------------------------- * @param integer $time 过期时间 * @param boolean $add 是否为增加时间 +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ static function setExpire($time, $add = false) { if ($add) { if (!isset($_SESSION['__HTTP_Session_Expire_TS'])) { $_SESSION['__HTTP_Session_Expire_TS'] = time() + $time; } // update session.gc_maxlifetime $currentGcMaxLifetime = Session::setGcMaxLifetime(null); Session::setGcMaxLifetime($currentGcMaxLifetime + $time); } elseif (!isset($_SESSION['__HTTP_Session_Expire_TS'])) { $_SESSION['__HTTP_Session_Expire_TS'] = $time; } } /** +---------------------------------------------------------- * 设置Session 闲置时间 +---------------------------------------------------------- * @param integer $time 闲置时间 * @param boolean $add 是否为增加时间 +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ static function setIdle($time, $add = false) { if ($add) { $_SESSION['__HTTP_Session_Idle'] = $time; } else { $_SESSION['__HTTP_Session_Idle'] = $time - time(); } } /** +---------------------------------------------------------- * 取得Session 有效时间 +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ static function sessionValidThru() { if (!isset($_SESSION['__HTTP_Session_Idle_TS']) || !isset($_SESSION['__HTTP_Session_Idle'])) { return 0; } else { return $_SESSION['__HTTP_Session_Idle_TS'] + $_SESSION['__HTTP_Session_Idle']; } } /** +---------------------------------------------------------- * 检查Session 是否过期 +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return boolean +---------------------------------------------------------- */ static function isExpired() { if (isset($_SESSION['__HTTP_Session_Expire_TS']) && $_SESSION['__HTTP_Session_Expire_TS'] < time()) { return true; } else { return false; } } /** +---------------------------------------------------------- * 检查Session 是否闲置 +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ static function isIdle() { if (isset($_SESSION['__HTTP_Session_Idle_TS']) && (($_SESSION['__HTTP_Session_Idle_TS'] + $_SESSION['__HTTP_Session_Idle']) < time())) { return true; } else { return false; } } /** +---------------------------------------------------------- * 更新Session 闲置时间 +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ static function updateIdle() { $_SESSION['__HTTP_Session_Idle_TS'] = time(); } /** +---------------------------------------------------------- * 设置Session 对象反序列化时候的回调函数 * 返回之前设置 +---------------------------------------------------------- * @param string $callback 回调函数方法名 +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return boolean +---------------------------------------------------------- */ static function setCallback($callback = null) { $return = ini_get('unserialize_callback_func'); if (!empty($callback)) { ini_set('unserialize_callback_func',$callback); } return $return; } /** +---------------------------------------------------------- * 设置Session 是否使用cookie * 返回之前设置 +---------------------------------------------------------- * @param boolean $useCookies 是否使用cookie +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return boolean +---------------------------------------------------------- */ static function useCookies($useCookies = null) { $return = ini_get('session.use_cookies') ? true : false; if (isset($useCookies)) { ini_set('session.use_cookies', $useCookies ? 1 : 0); } return $return; } /** +---------------------------------------------------------- * 检查Session 是否新建 +---------------------------------------------------------- * @param boolean $useCookies 是否使用cookie +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return boolean +---------------------------------------------------------- */ static function isNew() { return !isset($_SESSION['__HTTP_Session_Info']) || $_SESSION['__HTTP_Session_Info'] == HTTP_SESSION_STARTED; } /** +---------------------------------------------------------- * 取得当前项目的Session 值 * 返回之前设置 +---------------------------------------------------------- * @param string $name +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return boolean +---------------------------------------------------------- */ static function getLocal($name) { $local = Session::localName(); if (!is_array($_SESSION[$local])) { $_SESSION[$local] = array(); } return $_SESSION[$local][$name]; } /** +---------------------------------------------------------- * 取得当前项目的Session 值 * 返回之前设置 +---------------------------------------------------------- * @param string $name +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return boolean +---------------------------------------------------------- */ static function get($name) { if(isset($_SESSION[$name])) { return $_SESSION[$name]; }else { return null; } } /** +---------------------------------------------------------- * 设置当前项目的Session 值 * 返回之前设置 +---------------------------------------------------------- * @param string $name * @param mixed $value +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return boolean +---------------------------------------------------------- */ static function setLocal($name, $value) { $local = Session::localName(); if (!is_array($_SESSION[$local])) { $_SESSION[$local] = array(); } if (null === $value) { unset($_SESSION[$local][$name]); } else { $_SESSION[$local][$name] = $value; } return; } /** +---------------------------------------------------------- * 设置当前项目的Session 值 * 返回之前设置 +---------------------------------------------------------- * @param string $name * @param mixed $value +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return boolean +---------------------------------------------------------- */ static function set($name, $value) { if (null === $value) { unset($_SESSION[$name]); } else { $_SESSION[$name] = $value; } return ; } /** +---------------------------------------------------------- * 检查Session 值是否已经设置 +---------------------------------------------------------- * @param string $name +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return boolean +---------------------------------------------------------- */ static function is_setLocal($name) { $local = Session::localName(); return isset($_SESSION[$local][$name]); } /** +---------------------------------------------------------- * 检查Session 值是否已经设置 +---------------------------------------------------------- * @param string $name +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return boolean +---------------------------------------------------------- */ static function is_set($name) { return isset($_SESSION[$name]); } /** +---------------------------------------------------------- * 设置或者获取 Session localname +---------------------------------------------------------- * @param string $name +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ static function localName($name = null) { $return = (isset($GLOBALS['__HTTP_Session_Localname'])) ? $GLOBALS['__HTTP_Session_Localname'] : null; if (!empty($name)) { $GLOBALS['__HTTP_Session_Localname'] = md5($name); } return $return; } /** +---------------------------------------------------------- * Session 初始化 +---------------------------------------------------------- * @static * @access private +---------------------------------------------------------- * @return boolean +---------------------------------------------------------- */ static function _init() { ini_set('session.auto_start', 0); if (is_null(Session::detectID())) { Session::id(uniqid(dechex(mt_rand()))); } // 设置Session有效域名 Session::setCookieDomain(C('COOKIE_DOMAIN')); //设置当前项目运行脚本作为Session本地名 Session::localName(APP_NAME); Session::name(C('SESSION_NAME')); Session::path(C('SESSION_PATH')); Session::setCallback(C('SESSION_CALLBACK')); } /** +---------------------------------------------------------- * 设置Session use_trans_sid * 返回之前设置 +---------------------------------------------------------- * @param string $useTransSID +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ static function useTransSID($useTransSID = null) { $return = ini_get('session.use_trans_sid') ? true : false; if (isset($useTransSID)) { ini_set('session.use_trans_sid', $useTransSID ? 1 : 0); } return $return; } /** +---------------------------------------------------------- * 设置Session cookie_domain * 返回之前设置 +---------------------------------------------------------- * @param string $sessionDomain +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ static function setCookieDomain($sessionDomain = null) { $return = ini_get('session.cookie_domain'); if(!empty($sessionDomain)) { ini_set('session.cookie_domain', $sessionDomain);//跨域访问Session } return $return; } /** +---------------------------------------------------------- * 设置Session gc_maxlifetime值 * 返回之前设置 +---------------------------------------------------------- * @param string $gc_maxlifetime +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ static function setGcMaxLifetime($gcMaxLifetime = null) { $return = ini_get('session.gc_maxlifetime'); if (isset($gcMaxLifetime) && is_int($gcMaxLifetime) && $gcMaxLifetime >= 1) { ini_set('session.gc_maxlifetime', $gcMaxLifetime); } return $return; } /** +---------------------------------------------------------- * 设置Session gc_probability 值 * 返回之前设置 +---------------------------------------------------------- * @param string $gc_maxlifetime +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ static function setGcProbability($gcProbability = null) { $return = ini_get('session.gc_probability'); if (isset($gcProbability) && is_int($gcProbability) && $gcProbability >= 1 && $gcProbability <= 100) { ini_set('session.gc_probability', $gcProbability); } return $return; } /** +---------------------------------------------------------- * 当前Session文件名 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ static function getFilename() { return Session::path().'/sess_'.session_id(); } }//类定义结束 Session::_init();