Mã thông báo phiên là các chuỗi (hoặc đối tượng) do người dùng tạo để theo dõi các lệnh gọi Tự động hoàn thành (Mới) dưới dạng phiên. Tính năng Tự động hoàn thành (Mới) sử dụng mã thông báo phiên để nhóm các giai đoạn truy vấn và lựa chọn của một cụm từ tìm kiếm tự động hoàn thành của người dùng thành một phiên riêng biệt cho mục đích thanh toán.
Người dùng chịu trách nhiệm tạo mã thông báo phiên cho mỗi phiên. Mã thông báo phiên phải là chuỗi base64 an toàn cho URL và tên tệp. Người dùng có thể tạo mã thông báo phiên theo bất kỳ cách nào, mặc dù Google đề xuất sử dụng giá trị nhận dạng duy nhất (UUID) phiên bản 4 cho mã thông báo phiên.
Phiên bắt đầu bằng một lệnh gọi đến tính năng Tự động hoàn thành (Mới) và kết thúc bằng một lệnh gọi đến Chi tiết về địa điểm (Mới) hoặc Xác thực địa chỉ. Mỗi phiên có thể có nhiều truy vấn Tự động hoàn thành (Mới), sau đó là một yêu cầu đến Chi tiết về địa điểm (Mới) hoặc Xác thực địa chỉ. (Các) khoá API được dùng cho mỗi yêu cầu trong một phiên phải thuộc cùng một dự án trên Google Cloud Console.
Mã thông báo phiên sẽ kết thúc theo những cách sau:
Place Details (New) được gọi.
Xác thực địa chỉ được gọi.
Phiên này đã bị bỏ dở.
Sau khi một phiên kết thúc, mã thông báo sẽ không còn hợp lệ nữa; ứng dụng của bạn phải tạo mã thông báo mới cho mỗi phiên mới. Nếu bạn bỏ qua thông số sessionToken hoặc nếu bạn sử dụng lại mã thông báo phiên, thì phiên mới sẽ bị tính phí như thể bạn không cung cấp mã thông báo phiên (mỗi yêu cầu sẽ được tính phí riêng).
[null,null,["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[[["\u003cp\u003eSession tokens track Autocomplete (New) calls as sessions for billing purposes, grouping query and selection phases.\u003c/p\u003e\n"],["\u003cp\u003eUsers must create URL- and filename-safe base64 strings as session tokens for each session, ideally using version 4 UUIDs.\u003c/p\u003e\n"],["\u003cp\u003eA session starts with an Autocomplete (New) call and ends with a Place Details (New) or Address Validation call, allowing multiple Autocomplete queries within the session.\u003c/p\u003e\n"],["\u003cp\u003eSession tokens expire after a Place Details (New) or Address Validation call, if abandoned, or if reused; a new token is needed for each session.\u003c/p\u003e\n"],["\u003cp\u003eOmitting or reusing session tokens results in each request being billed separately, instead of as a session.\u003c/p\u003e\n"]]],["To use this feature, enable Places API (New). Session tokens, which are URL-safe base64 strings (ideally UUIDs), group autocomplete queries and selections into sessions for billing. A session begins with an Autocomplete (New) call and ends with a Place Details (New) or Address Validation call. Each session can contain several autocomplete queries. Tokens are single-use per session; reusing them or omitting them results in per-request billing.\n"],null,["\u003cbr /\u003e\n\n| This feature requires that you enable Places API (New), the next generation of the Places API. For more information, see [Enable APIs](/maps/documentation/places/ios-sdk/cloud-setup#enabling-apis).\n\n\u003cbr /\u003e\n\n\nSelect platform: [Android](/maps/documentation/places/android-sdk/place-session-tokens \"View this page for the Android platform docs.\") [iOS](/maps/documentation/places/ios-sdk/place-session-tokens \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/session-pricing \"View this page for the JavaScript platform docs.\") [Web Service](/maps/documentation/places/web-service/place-session-tokens \"View this page for the Web Service platform docs.\")\n\n\u003cbr /\u003e\n\nSession tokens\n==============\n\nSession tokens are user-generated strings (or objects) that track [Autocomplete (New)](/maps/documentation/places/ios-sdk/place-autocomplete)\ncalls as *sessions*. Autocomplete (New) uses session tokens to group the query\nand selection phases of a user autocomplete search into a discrete session for\nbilling purposes.\n\nUsers are responsible for creating session tokens for each session. Session\ntokens must be URL- and filename-safe base64 strings. Users can generate session\ntokens in any manner, although Google recommends using [version 4 universally\nunique identifiers (UUIDs)](https://tools.ietf.org/html/rfc4122) for session tokens.\n\nThe session begins with a call to Autocomplete (New), and concludes with a call\nto [Place Details (New)](/maps/documentation/places/ios-sdk/details-place) or [Address Validation](/maps/documentation/address-validation/overview). Each session can have\nmultiple Autocomplete (New) queries, followed by one request to Place Details\n(New) or Address Validation. The API key(s) used for each request within a\nsession must belong to the same Google Cloud Console project.\n| **Note:** Session tokens cannot be exchanged between Places API (Legacy) endpoints and Places API (New) or Address Validation endpoints. For example, a [Place Autocomplete (Legacy)](/maps/documentation/places/ios-sdk/autocomplete) request can be followed by a Place Details (Legacy) request in the same session, but it cannot be followed by a Place Details (New) request or an Address Validation request in the same session.\n\nSession tokens terminate in the following ways:\n\n- Place Details (New) is called.\n- Address Validation is called.\n- The session is abandoned.\n\n| **Note:** You can optionally omit the Autocomplete (New) session token from a request. If the session token is omitted, each request is billed separately and charges the [SKU: Autocomplete Requests](/maps/billing-and-pricing/sku-details#places_autocomplete-request-new-ess-sku).\n\nOnce a session has concluded, the token is no longer valid; your app must\ngenerate a fresh token for each new session. If the `sessionToken` parameter is\nomitted, or if you reuse a session token, the new session is charged as if no\nsession token was provided (each request is billed separately).\n\nFor more information about how Autocomplete (New) requests are billed, see\n[Autocomplete (New) and session pricing](/maps/documentation/places/ios-sdk/session-pricing)."]]