MadelineProto/docs/docs/CREATING_A_CLIENT.md

23 lines
1.2 KiB
Markdown
Raw Normal View History

# Creating a client
To store information about an account session and avoid re-logging in, serialization must be done.
A MadelineProto session is automatically serialized every `$MadelineProto->settings['serialization']['serialization_interval']` seconds (by default 30 seconds), and on shutdown. If the scripts shutsdown normally (without ctrl+c or fatal errors/exceptions), the session will also be serialized automatically.
To create the session and set the serialization destination file, do the following:
2018-03-20 13:04:44 +01:00
```php
$MadelineProto = new \danog\MadelineProto\API('session.madeline', $settings); // The session will be serialized to session.madeline
```
Do the same to load a serialized session:
2018-03-20 13:04:44 +01:00
```php
$MadelineProto = new \danog\MadelineProto\API('session.madeline', $settings); // The session will be loaded from session.madeline
```
To change the session file after starting MadelineProto, do the following:
2018-03-20 13:04:44 +01:00
```php
2018-03-20 16:02:36 +01:00
$MadelineProto->session = 'newsession.madeline';
2018-03-20 20:43:11 +01:00
```
2018-03-21 10:53:02 +01:00
<form action="https://docs.madelineproto.xyz"><input type="submit" value="Previous section" /></form><form action="https://docs.madelineproto.xyz/docs/LOGIN.html"><input type="submit" value="Next section" /></form>