# easysessions

> sessions n shit

Latest version **1.0.1** (published 2021-07-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install easysessions
pnpm add easysessions
yarn add easysessions
bun add easysessions
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-07-22 |
| First published | 2021-07-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Phaze#6193 |
| Maintainers | wiresdev |

## Links

- npm: https://www.npmjs.com/package/easysessions
- npm.io page: https://npm.io/package/easysessions

## Recent versions

- 1.0.1 (latest) — 2021-07-22
- 1.0.0 — 2021-07-22

## README

Install

```
npm i easysessions
```

Creating a session
```js
const sessions = require('easysessions');

console.log(sessions.create(500)) // You can change the timeout time.
// This will return a string of numbers (the session id). 
```

Checking if a session exists
```js
const sessions = require('easysessions');

console.log(sessions.check(sessionID))
// Will return true or false
```

Creating a session that never expires
```js
const sessions = require('easysessions');

console.log(sessions.create1Time())
// This will return a string of numbers (the session id). 
```

Once you want to delete this session you can use
```js
const sessions = require('easysessions');

sessions.delete(id)
```

Examples Of Use:
```js
const express = require('express');
const sessions = require('easysessions');
const app = express();

app.get('/', (req, res) => {
    res.render('index.ejs', {
        session: sessions.create1Time()
    })// The page loads with a infinate session
})

app.post('/api/v1/someapi/:session', function(req, res){
    if(sessions.check(req.params.session)){
        sessions.delete(req.params.session)

        res.json({ ok: true })
    } else{
        res.json({ error: "Invaild Session" })
    }
})// Have an api callback with a session in the url

app.listen(80)
```

Client Side:
```html
<button onclick="submit()">Test</button>

<script>
    function submit(){
        fetch('./api/v1/someapi/<%= session %>', {
            method: "POST",
        }).then(data => data.json()).then(data => {
            if(data.error)return console.log('Session was invaild')

            if(data.ok){
                console.log('Session was correct')
            }
        })
    }
</script>
```

---
_Source: https://npm.io/package/easysessions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
