private function createSession(string $timezone): bool {

		// checks if time zone name is valid
		if (!in_array($timezone, \DateTimeZone::listIdentifiers())) {
			$timezone = date_default_timezone_get();
		}
		
		// gets offset by timezone name
		$dt = new \DateTime('now', new \DateTimeZone($timezone));
		$diff = $dt->format('P');
		list ($hours, $mins) = explode(':', $diff);
		$offset = (float)$hours + ($hours > 0 ? ($mins / 60) : -($mins / 60));

		// creates session
		$session = new Session();

		$session->id				= session_id();
		$session->idUser			= $this->id;
		$session->startTime			= new \DateTime();
		$session->timezoneOffset	= $offset;
		$session->timezoneName		= $timezone;
		
		$res1 = $session->create();
		
		// updates last user login
		$this->lastLogin	= new \DateTime();
		$this->tzOffset		= $offset;
		$this->tzName		= $timezone;
		
		$res2 = $this->update('lastLogin');

		return ($res1 and $res2);
		
	}
private function createSession(string $timezone): bool {

		// checks if time zone name is valid
		if (!in_array($timezone, \DateTimeZone::listIdentifiers())) {
			$timezone = date_default_timezone_get();
		}
		
		// gets offset by timezone name
		$dt = new \DateTime('now', new \DateTimeZone($timezone));
		$diff = $dt->format('P');
		list ($hours, $mins) = explode(':', $diff);
		$offset = (float)$hours + ($hours > 0 ? ($mins / 60) : -($mins / 60));

		// creates session
		$session = new Session();

		$session->id				= session_id();
		$session->idUser			= $this->id;
		$session->startTime			= new \DateTime();
		$session->timezoneOffset	= $offset;
		$session->timezoneName		= $timezone;
		
		$res1 = $session->create();
		
		// updates last user login
		$this->lastLogin	= new \DateTime();
		$this->tzOffset		= $offset;
		$this->tzName		= $timezone;
		
		$res2 = $this->update('lastLogin');

		return ($res1 and $res2);
		
	}
private function createSession ( string $ timezone ) : bool { // checks if time zone name is valid if ( ! in_array ( $ timezone , \ DateTimeZone :: listIdentifiers ( ) ) ) { $ timezone = date_default_timezone_get ( ) ; } // gets offset by timezone name $ dt = new \ DateTime ( 'now' , new \ DateTimeZone ( $ timezone ) ) ; $ diff = $ dt -> format ( 'P' ) ; list ( $ hours , $ mins ) = explode ( ':' , $ diff ) ; $ offset = ( float ) $ hours + ( $ hours > 0 ? ( $ mins / 60 ) : - ( $ mins / 60 ) ) ; // creates session $ session = new Session ( ) ; $ session -> id = session_id ( ) ; $ session -> idUser = $ this -> id ; $ session -> startTime = new \ DateTime ( ) ; $ session -> timezoneOffset = $ offset ; $ session -> timezoneName = $ timezone ; $ res1 = $ session -> create ( ) ; // updates last user login $ this -> lastLogin = new \ DateTime ( ) ; $ this -> tzOffset = $ offset ; $ this -> tzName = $ timezone ; $ res2 = $ this -> update ( 'lastLogin' ) ; return ( $ res1 and $ res2 ) ; }
Starts a new session, writes on db and updates users table for last login.
Returns true if both db writing has been done succesfully.

@param	string	IANA time zone identifier.

@return	bool
Starts a new session writes on db and updates users table for last login . Returns true if both db writing has been done succesfully .