english/libraries/joomla/application/application.php
/**
	 * Create the user session.
	 *
	 * Old sessions are flushed based on the configuration value for the cookie
	 * lifetime. If an existing session, then the last access time is updated.
	 * If a new session, a session id is generated and a record is created in
	 * the #__sessions table.
	 *
	 * @param   string  $name  The sessions name.
	 *
	 * @return  JSession  JSession on success. May call exit() on database error.
	 *
	 * @since   11.1
	 */
Create the user session.
Old sessions are flushed based on the configuration value for the cookie
lifetime. If an existing session, then the last access time is updated.
If a new session, a session id is generated and a record is created in
the #__sessions table.

@param   string  $name  The sessions name.




Create the user session . Old sessions are flushed based on the configuration value for the cookie lifetime . If an existing session then the last access time is updated . If a new session a session id is generated and a record is created in the #__sessions table . @param string $name The sessions name .
protected function _createSession($name)
	{
		$options = array();
		$options['name'] = $name;
		switch($this->_clientId)
		{
			case 0:
				if ($this->getCfg('force_ssl') == 2) {
					$options['force_ssl'] = true;
				}
				break;
			case 1:
				if ($this->getCfg('force_ssl') >= 1) {
					$options['force_ssl'] = true;
				}
				break;
		}
		$session = JFactory::getSession($options);
		$db = JFactory::getDBO();
		$time = time();
		if ($time % 2) {
			$db->setQuery(
				'DELETE FROM `#__session`' .
				' WHERE `time` < '.(int) ($time - $session->getExpire())
			);
			$db->query();
		}
		if (($this->getCfg('session_handler') != 'database' && ($time % 2 || $session->isNew()))
			||
			($this->getCfg('session_handler') == 'database' && $session->isNew())
		)
		{
			$this->checkSession();
		}
		return $session;
	}
protected function _createSession ( $ name ) { $ options = array ( ) ; $ options [ 'name' ] = $ name ; switch ( $ this -> _clientId ) { case 0 : if ( $ this -> getCfg ( 'force_ssl' ) == 2 ) { $ options [ 'force_ssl' ] = true ; } break ; case 1 : if ( $ this -> getCfg ( 'force_ssl' ) >= 1 ) { $ options [ 'force_ssl' ] = true ; } break ; } $ session = JFactory :: getSession ( $ options ) ; $ db = JFactory :: getDBO ( ) ; $ time = time ( ) ; if ( $ time % 2 ) { $ db -> setQuery ( 'DELETE FROM `#__session`' . ' WHERE `time` < ' . ( int ) ( $ time - $ session -> getExpire ( ) ) ) ; $ db -> query ( ) ; } if ( ( $ this -> getCfg ( 'session_handler' ) != 'database' && ( $ time % 2 || $ session -> isNew ( ) ) ) || ( $ this -> getCfg ( 'session_handler' ) == 'database' && $ session -> isNew ( ) ) ) { $ this -> checkSession ( ) ; } return $ session ; }
Create the user session.
Create the user session .
//TODO: At some point we need to get away from having session data always in the db. // Remove expired sessions from the database. // The modulus introduces a little entropy, making the flushing less accurate // but fires the query less than half the time. // Check to see the the session already exists.