Class WC_Session_Handler

Handle data for the current customers session. Implements the WC_Session abstract class

Long term plan will be, if https://github.com/ericmann/wp-session-manager/ gains traction in WP core, this will be switched out to use it and maintain backwards compatibility :)

Partly based on WP SESSION by Eric Mann.

WC_Session
Extended by WC_Session_Handler
Package: WooCommerce\Classes
Category: Class
Author: WooThemes
Version: 2.0.0
Class: WC_Session_Handler
Located at includes/class-wc-session-handler.php

Methods summary

public
# __construct( )

Constructor for the session class.

Constructor for the session class.

public
# set_customer_session_cookie( mixed $set )

Sets the session cookie on-demand (usually after adding an item to the cart).

Sets the session cookie on-demand (usually after adding an item to the cart).

Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set.

Warning: Cookies will only be set if this is called before the headers are sent.

public boolean
# has_session( )

Return true if the current user has an active session, i.e. a cookie to retrieve values

Return true if the current user has an active session, i.e. a cookie to retrieve values

Returns

boolean
public
# set_session_expiration( )

set_session_expiration function.

set_session_expiration function.

public integer|string
# generate_customer_id( )

Generate a unique customer ID for guests, or return user ID if logged in.

Generate a unique customer ID for guests, or return user ID if logged in.

Uses Portable PHP password hashing framework to generate a unique cryptographically strong ID.

Returns

integer|string
public mixed
# get_session_cookie( )

get_session_cookie function.

get_session_cookie function.

Returns

mixed
public array
# get_session_data( )

get_session_data function.

get_session_data function.

Returns

array
public
# save_data( )

save_data function.

save_data function.

public
# cleanup_sessions( )

cleanup_sessions function.

cleanup_sessions function.

Methods inherited from WC_Session

__get(), __isset(), __set(), __unset(), get(), get_customer_id(), set()

Magic methods summary

Properties summary

Properties inherited from WC_Session

$_customer_id, $_data, $_dirty

WooCommerce API documentation generated by ApiGen 2.8.0