PHPackages                             bibrkacity/sanctum\_session - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. bibrkacity/sanctum\_session

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

bibrkacity/sanctum\_session
===========================

Supporting work with variables related to Sanctum token

v1.1.4(2mo ago)014MITPHPPHP ^8.2

Since Mar 20Pushed 2mo agoCompare

[ Source](https://github.com/bibrkacity/sanctum_session)[ Packagist](https://packagist.org/packages/bibrkacity/sanctum_session)[ RSS](/packages/bibrkacity-sanctum-session/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (4)Versions (17)Used By (0)

Sanctum Session
===============

[](#sanctum-session)

Supporting work with variables related to Sanctum token For Laravel. It can be called "Sanctum Session". It can be useful, for example, for storing user preferences or user-specific data.

- [Installation](#installation)
- [Usage](#usage)
    - [Examples](#examples)
- [Prune old Sanctum session variables](#prune-old-sanctum-session-variables)

Installation
------------

[](#installation)

1. Run
    `composer require bibrkacity/sanctum_session`
    from the root of your project.
2. Run
    `php artisan vendor:publish --provider="Bibrkacity\SanctumSession\SanctumSessionServiceProvider"`
     from the root of your project.
3. Run
    `php artisan migrate`
     from the root of your project.

Usage
-----

[](#usage)

The alias `SanctumService` available in your project after installation. The token for use as argument in the methods you can get from the request:

```
$token = request()->bearerToken();
// or
$token = $request->bearerToken();
```

Available types of variables:

- string
- integer
- float
- boolean
- array
- object
- json

The alias `SanctumService` has a static methods for work with the Sanctum session variables:

MethodArgumentsDescriptionhas()string $token,
 string $keyChecking if a variable with name=$key exists in the Sanctum sessionget()string $token,
 string $key,
mixed $defaultGetting a variable from the Sanctum sessiongetAll()string $tokenGetting all variables from the Sanctum sessionput()string $token,
string $key,
string $type,
mixed $valueSetting a variable in the Sanctum sessionforget()string $token,
 string $keyRemoving a variable from the Sanctum sessionforgetAll()string $tokenRemoving all variables from the Sanctum session### Examples

[](#examples)

1. Middleware for get/set locale using the Sanctum session:

```
