--- title: Browser SDK Setup | SafetyKit description: Create a SafetyKit identity session before loading the browser SDK. --- ## Server Setup Create a SafetyKit identity session from server-side code before rendering pages that load the browser SDK. This call uses the SafetyKit server SDK against the normal authenticated SafetyKit API, such as `api.safetykit.com`. ``` require "safety_kit" class ApplicationController def safetykit_client_session attributes = {} attributes[:user_id] = current_user.id if logged_in? attributes[:customer_session_id] = session.id if session&.id safetykit.client_sessions.create_session(**attributes) end end ``` `user_id` and `customer_session_id` are optional. Omit them when they are not available. See the [`client_sessions.create_session` API reference](/api/ruby/resources/client_sessions/methods/createSession/index.md) for the full Ruby method signature, request parameters, and response fields.