LLMS_Abstract_Session_Data::generate_id()

Generate a session key for the current user/visitor.


Description Description

A logged-in user will use their WP_User ID while logged-out users will be assigned a random string.


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/abstracts/llms-abstract-session-data.php

	protected function generate_id() {

		// Use the current user id if the user is logged in.
		if ( is_user_logged_in() ) {
			return strval( get_current_user_id() );
		}

		// Generate a random id.
		require_once ABSPATH . 'wp-includes/class-phpass.php';
		$hasher = new PasswordHash( 8, false );
		return md5( $hasher->get_random_bytes( 32 ) );

	}


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.