Skip to Content


Generates a unique session ID with detailed information about the user.

PHP August 17, 2017




This function does not accept any parameters. Is this incorrect?

Additional Notes


Default Components

  • t – Server-side UTC timestamp of the last pageview in the session.
  • d – Debug mode
  • p – Prototype mode
  • cli – Client user (Matched by IP address or logged-in email domain)
  • dev – Developer user (Matched by IP address or logged-in email domain)
  • r – Logged-in WordPress user role
  • uid – Logged-in WordPress user ID
  • bot – Known bot
  • l – If the site is not live (using is_site_live()) Note: Only appears if false
  • s – Session ID or Unique ID (Note: unique ID is prepended with !)
  • cid – Google Analytics CID
    • This is parsed from the Google Analytics cookie (two numbers separated by .) or generated by Nebula (four groups of numbers separated by -)
    • The first number in the GA cookie is a random ID and the second is a UTC timestamp of the user’s first visit.
    • This is an ID tied to the user and can be used to track multiple sessions.

Use the filter nebula_session_id to add more values to this session ID. Remember that this value is accessible in the page source, so data may be seen by the visitor. Important: Do not add personally identifiable information to this session ID! This data is stored in Google Analytics where PII is against the Terms of Service.

Follow the Nebula Recommendations to create custom dimensions including one for Session ID so it can provide context to visitor data in Google Analytics.


  • This information can be sent with all Contact Form 7 forms by including a hidden filed with the class debuginfo.
  • Use these to create a segment within Google Analytics to focus only on important traffic.
  • Create temporary segments or report filters to track individual users with their CID.
  • On initial visit, Nebula generates a CID which is replaced via JavaScript when an actual Google Analytics Client ID is generated.
    • If the Nebula version remains it indicates that Google Analytics or JavaScript is blocked.
Was this page helpful? Yes No

    A feedback message is required to submit this form.

    Please check that you have entered a valid email address.

    Enter your email address if you would like a response.

    Thank you for your feedback!

    Source File

    Located in /libs/Utilities/Utilities.php on line 74.

    2 Hooks

    Find these filters and actions in the source code below to hook into them. Use do_action() and add_filter() in your functions file or plugin.

    Need a new filter hook? Request one here.

    Need a new action hook? Request one here.

            public function nebula_session_id(){
                $cache_group = uniqid(); //Each "user" gets its own group so it persists without interfering with each other
                //Check object cache first
                $session_id = wp_cache_get('nebula_session_id', $cache_group); //If session_id() is not available, it will re-generate the Nebula session ID
                if ( !empty($session_id) ){
                    return sanitize_text_field($session_id);
                $timer_name = $this->timer('Session ID');
                $session_data = array();
                $session_data['t'] = time();
                if ( $this->is_debug() ){
                    $session_data['d'] = true;
                if ( $this->is_client() ){
                    $session_data['cli'] = true;
                if ( $this->is_dev() ){
                    $session_data['dev'] = true;
                //Logged in user role
                if ( is_user_logged_in() ){
                    $user_info = get_userdata(get_current_user_id());
                    $session_data['r'] = 'unknown';
                    if ( !empty($user_info->roles) ){
                        $session_data['r'] = $user_info->roles[0];
                    $session_data['uid'] = get_current_user_id();
                //Bot detection
                if ( $this->is_bot() ){
                    $session_data['bot'] = true;
                //Site Live
                if ( !$this->is_site_live() ){
                    $session_data['l'] = false;
                //Session ID
                $session_data['s'] = $cache_group; //Use the unique ID that determines the group as the main ID
                //Google Analytics CID
                $session_data['cid'] = $this->ga_parse_cookie();
                //Additional session information
                $all_session_data = apply_filters('nebula_session_id', $session_data);
                //Convert to a string
                $session_id = '';
                foreach ( $all_session_data as $key => $value ){
                    $session_id .= $key . ':' . $value . ';';
                //do_action('qm/info', 'Nebula Session ID: ' . $session_id);
                wp_cache_set('nebula_session_id', $session_id, $cache_group); //Store in object cache grouped by the unique ID to prevent interference
                $this->timer($timer_name, 'end');
                return sanitize_text_field($session_id);


    This function can not be short-circuited with an override filter. Request one?