Initialize the session cookie

Description Description

Retrieves and validates the cookie, when there’s a valid cookie it will initialize the object with data from the cookie. Otherwise it sets up and saves a new session and cookie.

Top ↑

Return Return


Top ↑

Source Source

File: includes/class.llms.session.php

	protected function init_cookie() {

		$cookie = $this->get_cookie();

		$set_cookie = false;

		if ( $cookie ) {

			$this->id       = $cookie[0];
			$this->expires  = $cookie[1];
			$this->expiring = $cookie[2];
			$this->data     = $this->read( $this->id );

			// If the user has logged in, update the session data.
			$update_id = $this->maybe_update_id();

			// If the session is nearing expiration, update the session.
			$extend_expiration = $this->maybe_extend_expiration();

			// If either of these two items are true, the cookie needs to be updated.
			$set_cookie = $update_id || $extend_expiration;

		} else {

			$this->id       = $this->generate_id();
			$this->data     = array();
			$this->is_clean = false;
			$set_cookie     = true;


		if ( $set_cookie ) {


Top ↑

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.