本文整理汇总了PHP中fSession::normal_timespan方法的典型用法代码示例。如果您正苦于以下问题:PHP fSession::normal_timespan方法的具体用法?PHP fSession::normal_timespan怎么用?PHP fSession::normal_timespan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fSession
的用法示例。
在下文中一共展示了fSession::normal_timespan方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setLength
/**
* Sets the minimum length of a session - PHP might not clean up the session data right away once this timespan has elapsed
*
* Please be sure to set a custom session path via ::setPath() to ensure
* another site on the server does not garbage collect the session files
* from this site!
*
* Both of the timespan can accept either a integer timespan in seconds,
* or an english description of a timespan (e.g. `'30 minutes'`, `'1 hour'`,
* `'1 day 2 hours'`).
*
* @param string|integer $normal_timespan The normal, session-based cookie, length for the session
* @param string|integer $persistent_timespan The persistent, timed-based cookie, length for the session - this is enabled by calling ::enabledPersistence() during login
* @return void
*/
public static function setLength($normal_timespan, $persistent_timespan = NULL)
{
if (self::$open || isset($_SESSION)) {
throw new fProgrammerException('%1$s must be called before any of %2$s, %3$s, %4$s, %5$s, %6$s, %7$s or %8$s', __CLASS__ . '::setLength()', __CLASS__ . '::add()', __CLASS__ . '::clear()', __CLASS__ . '::enablePersistence()', __CLASS__ . '::get()', __CLASS__ . '::open()', __CLASS__ . '::set()', 'session_start()');
}
$seconds = !is_numeric($normal_timespan) ? strtotime($normal_timespan) - time() : $normal_timespan;
self::$normal_timespan = $seconds;
if ($persistent_timespan) {
$seconds = !is_numeric($persistent_timespan) ? strtotime($persistent_timespan) - time() : $persistent_timespan;
self::$persistent_timespan = $seconds;
}
ini_set('session.gc_maxlifetime', $seconds);
}