#2140 - User tracking system (to replace cookies) This is a spacer post for a website comment topic. The content this topic relates to: #2140 - User tracking system (to replace cookies) By Guest posted 14th Aug 2018, 8:04 AM Do not fill this field in. https://github.com/mikewest/http-state-tokens By Guest posted 7th Dec 2022, 8:57 AM I defined this on a client site with thoughts about using it in the future... $GLOBALS['SITE_DB']->create_table('session_data', array( 's_session_id' => '*ID_TEXT', 's_key' => '*ID_TEXT', 's_val' => 'LONG_TEXT', )); function get_session_val($key) { return $GLOBALS['SITE_DB']->query_select_value_if_there('session_data', 's_val', array( 's_session_id' => get_session_id(true), 's_key' => $key, )); } function set_session_val($key, $val) { $GLOBALS['SITE_DB']->query_delete('session_data', array( 's_session_id' => get_session_id(true), 's_key' => $key, )); if ($val !== null) { $GLOBALS['SITE_DB']->query_insert('session_data', array( 's_session_id' => get_session_id(true), 's_key' => $key, 's_val' => $val, )); } } The query_delete/query_insert combo could be replaced with query_insert_or_replace in v11+. By Guest posted 22nd Jun 2025, 7:40 PM Be careful... Implementation needs to consider cases where a user might actually want these values to be cleared (e.g. they clear their browser cookies). 0 guests and 0 members have recently viewed this. Sort: Relevance Newest first Oldest first Rating Popularity
$GLOBALS['SITE_DB']->create_table('session_data', array(
's_session_id' => '*ID_TEXT',
's_key' => '*ID_TEXT',
's_val' => 'LONG_TEXT',
));
function get_session_val($key)
{
return $GLOBALS['SITE_DB']->query_select_value_if_there('session_data', 's_val', array(
's_session_id' => get_session_id(true),
's_key' => $key,
));
}
function set_session_val($key, $val)
{
$GLOBALS['SITE_DB']->query_delete('session_data', array(
's_session_id' => get_session_id(true),
's_key' => $key,
));
if ($val !== null) {
$GLOBALS['SITE_DB']->query_insert('session_data', array(
's_session_id' => get_session_id(true),
's_key' => $key,
's_val' => $val,
));
}
}
The query_delete/query_insert combo could be replaced with query_insert_or_replace in v11+.
Implementation needs to consider cases where a user might actually want these values to be cleared (e.g. they clear their browser cookies).