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.

Source File

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

1 Hook

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.

This function has no action hooks available. Request one?

Note: This function contains 1 to-do comment.

        public function nebula_session_id(){
            $timer_name = $this->timer('Session ID');
            $server_generated_session_id = ( session_id() )? session_id() : '!' . uniqid(); //@todo "nebula" 0: decommission for session

            //Check object cache first
            $session_id = wp_cache_get('nebula_session_id', $server_generated_session_id); //If session_id() is not available, it will re-generate the Nebula session ID
            if ( !empty($session_id) ){
                return $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'] = $server_generated_session_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 . ';';

            wp_cache_set('nebula_session_id', $session_id, $server_generated_session_id); //Store in object cache grouped by the server-generated session ID
            $this->timer($timer_name, 'end');
            return $session_id;


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