User Settings and wpCookies

JS User Settings functions (Cookies and Options)

JS functions from the file wp-includes/js/utils.js. Inclusion:

wp_enqueue_script( 'utils' );

Functions for writing Cookies in JS

window.wpCookies.getHash( name )
Get a multi-values cookie. Returns a JS object with the name: 'value' pairs.
window.wpCookies.setHash( name, values_obj, expires, path, domain, secure )
Set a multi-values cookie. 'values_obj' is the JS object that is stored. It is encoded as URI in wpCookies.set().
window.wpCookies.get( name )
Get a cookie.
window.wpCookies.set( name, value, expires, path, domain, secure )
Set a cookie. The 'expires' arg can be either a JS Date() object set to the expiration date (back-compat) or the number of seconds until expiration
window.wpCookies.remove( name, path, domain, secure )
Remove a cookie. This is done by setting it to an empty value and setting the expiration time in the past.

JS User Settings Functions

window.getUserSetting( name, def )
Returns the value as string. Second arg or empty string is returned when value is not set.
window.setUserSetting( name, value, _del )
Both name and value must be only ASCII letters, numbers or underscore and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text. The value is converted and stored as string.
window.deleteUserSetting( name )
Deletes the specified option.
window.getAllUserSettings()
Returns all settings as js object.
window.getAllUserSettings()

/*
will return:
{
	align: "center"
	ed_size: "391"
	editor: "tinymce"
	editor_expand: "off"
	hidetb: "1"
	imgsize: "full"
	libraryContent: "browse"
	mfold: "o"
	posts_list_mode: "list"
	urlbutton: "file"
	wplink: "1"
}
*/

PHP User Settings Functions (options)

There are also related JS PHP functions for user options:

wp_user_settings( )
Saves and restores user interface settings stored in a cookie.
get_user_setting( $name, $default_value )
Retrieves user interface setting value based on setting name.
set_user_setting( $name, $value )
Adds or updates user interface setting.
delete_user_setting( $names )
Deletes user interface settings.
get_all_user_settings( )
Retrieves all user interface settings.
wp_set_all_user_settings( $user_settings )
Private. Sets all user interface settings.
delete_all_user_settings( )
Deletes the user settings of the current user.
print_r( get_all_user_settings() );

/*
will return:
Array
	[editor] => tinymce
	[wplink] => 1
	[editor_expand] => off
	[ed_size] => 391
	[posts_list_mode] => list
	[libraryContent] => browse
	[align] => center
	[imgsize] => full
	[urlbutton] => file
	[hidetb] => 1
	[mfold] => o
*/