LLMS_Abstract_Session_Database_Handler::save( int $expires )

Save the session to the database


Parameters Parameters

$expires

(int) (Required) Timestamp of the session expiration.


Top ↑

Return Return

(boolean)


Top ↑

Source Source

File: includes/abstracts/llms-abstract-session-database-handler.php

	public function save( $expires ) {

		// Only save if we have data to save.
		if ( $this->is_clean ) {
			return false;
		}

		global $wpdb;
		$save = $wpdb->query(  // phpcs:ignore: WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
			$wpdb->prepare(
				"INSERT INTO {$wpdb->prefix}lifterlms_sessions ( `session_key`, `data`, `expires` ) VALUES ( %s, %s, %d )
				ON DUPLICATE KEY UPDATE `data` = VALUES ( `data` ), `expires` = VALUES ( `expires` )",
				$this->get_id(),
				maybe_serialize( $this->data ),
				$expires
			)
		);

		wp_cache_set( $this->get_cache_key( $this->get_id() ), $this->data, $this->cache_group, $expires - time() );
		$this->is_clean = true;

		return (bool) $save;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
4.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.