MadelineProtoDocs/docs/docs/CREATING_A_CLIENT.md

28 lines
1.2 KiB
Markdown
Raw Normal View History

2018-04-11 14:17:45 +02:00
---
title: Creating a client
description: To store information about an account session and avoid re-logging in, serialization must be done.
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
2018-04-01 13:19:25 +02:00
# 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:
```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:
```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:
```php
$MadelineProto->session = 'newsession.madeline';
```
2018-04-01 13:55:07 +02:00
<a href="https://docs.madelineproto.xyz/docs/LOGIN.html">Next section</a>