How to find out session name of telegram app?

Viewed 345

I have created a telegram app via https://my.telegram.org. After I did that I got data about api_id and api_hash but I can't find session name. Where can I find it?

When I use telethon function TelegramClient, I need to pass there SESSION:

from telethon import TelegramClient

client = TelegramClient(SESSION, API_ID, API_HASH)

I can't find the session name

1 Answers

Where can I find it?

You cant, you'll need to create it.


Telethon sessions are used to save the data of your current session.

They're not part of the Telegram API, just something Telethon introduced.

The first parameter you pass to the constructor of the TelegramClient is the session, and defaults to be the session name (or full path). That is, if you create a TelegramClient('anon') instance and connect, an anon.session file will be created in the working directory.

The file name of the session file to be used if a string is given (it may be a full path), or the Session instance to be used otherwise. If it’s None, the session will not be saved, and you should call log_out() when you’re done.


You can just pass None (to not save a session), or a 'usefull' name like Anon:

client = TelegramClient('anon', '19071234', 'e40ef8a46648716835434')
client.start()
Related