export_session_string()

Client.export_session_string()

Export the current authorized session as a serialized string.

Session strings are useful for storing in-memory authorized sessions in a portable, serialized string. More detailed information about session strings can be found at the dedicated page of Storage Engines.

Returns

str – The session serialized into a printable, url-safe string.

Example

from pyrogram import Client

app = Client("my_account")

with app:
    print(app.export_session_string())