Git Product home page Git Product logo

session's Introduction

@adonisjs/session


gh-workflow-image npm-image license-image

Introduction

Use sessions in your AdonisJS applications with a unified API to persist session data across different data-stores. Has inbuilt support for cookie, files, and redis drivers.

Official Documentation

The documentation is available on the AdonisJS website

Contributing

One of the primary goals of AdonisJS is to have a vibrant community of users and contributors who believes in the principles of the framework.

We encourage you to read the contribution guide before contributing to the framework.

Code of Conduct

In order to ensure that the AdonisJS community is welcoming to all, please review and abide by the Code of Conduct.

License

AdonisJS session is open-sourced software licensed under the MIT license.

session's People

Contributors

bricklou avatar dependabot-preview[bot] avatar dependabot[bot] avatar juampi92 avatar julien-r44 avatar romainlanz avatar snyk-bot avatar targos avatar thetutlage avatar uybinhphan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

session's Issues

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organiszation’s settings page, under Installed GitHub Apps.

Disable session creation on certain routes

... or at least allow to trigger session creation manually.

Why this feature is required (specific use-cases will be appreciated)?

I don't want to create a session for every visitors of my website and I don't want to create a session on every routes either.

Have you tried any other work arounds?

I read the doc and didn't see a satisfying workaround.

Are you willing to work on it with little guidance?

Yes.

Deserializing ObjectID to ObjectId make wrong user login on adonis

Package version

1.0.28

Node.js and npm version

node v10.15.3 and npm 6.4.1

Sample Code (to reproduce the issue)

You only need these two methods on a controller to test it:

async test({ session }){
    const ObjectId = require('bson').ObjectId
    const id = new ObjectId('5c55d6cab44b5f6c2dc33544')
    session.put('test', id)

    return (id instanceof ObjectId)
  }

  async test2({ session }){
    const ObjectId = require('bson').ObjectId
    const idRecovered = session.get('test')
    const result = (idRecovered instanceof ObjectId)
    return result
  }

You will see as the test method returns true and the test2 returns false as the object store maps the ObjectId to ObjectId instead of ObjectID

The bson library exports ObjectId and ObjectID but the first one is just an alias to ObjectID.

I think you have addressed this problem in the last commit:
f713199

Could you please release a new version with this?

We are implementing a social login and we always end up logged with the first user in the mongo collection because of this (I don't know why as not be detecting the ObjectId correctly it returns all documents).

Missing bson dependancy

When installing fullstack-app I just got an error from adonis-session requiring missing bson dependency.
Adding it to main package.json fixed the issue.

Great work on the framework. <3

numerous number of files reside on session folder

Hi there,

I'm using AdonisJs version 4.1 but I faced with a problem on storing session.
I've atmost 650k unique visitor per month but the size of sessions directory has grown up to 16GB which is a little bit weird.

Is there someone who has had such problem?
Why does the size of sessions directory has grow in such way?

Any help will be appreciated.
Best regards.

Property `session` does not exist on type `HttpContextContract`

Package version

    "@adonisjs/core": "^5.8.0",
    "@adonisjs/repl": "^3.1.0",
    "@adonisjs/session": "^6.4.0",

Node.js and npm version

v16.14.2

Sample Code (to reproduce the issue)

Following the session docs here: https://docs.adonisjs.com/guides/session

I've set up config/session.ts for cookie storage:

import Env from "@ioc:Adonis/Core/Env";
import { sessionConfig } from "@adonisjs/session/build/config";

export default sessionConfig({
  enabled: true,
  driver: Env.get("SESSION_DRIVER"),
  cookieName: "adonis-session",
  clearWithBrowser: false,
  age: "2h",
  cookie: {
    path: "/",
    httpOnly: true,
    sameSite: false,
  },
  file: {},
  redisConnection: "local",
});

and set the following in .env:

SESSION_DRIVER=cookie

I'm trying to use the session in routes, as described in the docs:

Route.get("/", async ({ session }) => {
  session.put("test", "hmm");
  return { hello: "world" };
});

session is highlighted as a problem in VS Code, with the error message "Property session does not exist on type HttpContextContract" — and requesting the / route in my browser shows that session is not defined.

Are the docs up to date? Is my SESSION_DRIVER correct? How do I access and modify the session?

a new session file for each new request from mobile app

Hi there,

I'm using AdonisJs version 4.1 but I faced with a problem when making requests from mobile app to my api.
When making request it will create a new session file for each new request.

Example:
Fetching categories in the home screen of app will create a new session file. When clicking on category it will fetch the products for that category and this request will create also a new session file.

Is there a way to create only one session file for making the request from mobile app?

Any help will be appreciated.
Best regards.

expires on session put

it would be a great feature to have an expires value that can be used with the put function. As maybe you want to store something on the session but it isn't required for a long period of time, and thus it will help prevent the session data building up.

Yes you could use redis directly, but this would be easier when wanting to store something on a specific session.

session put data issue

Prerequisites

We do our best to reply to all the issues on time. If you will follow the given guidelines, the turn around time will be faster.

  • Lots of raised issues are directly not bugs but instead are design decisions taken by us.
  • Make use of our forum, or discord server, if you are not sure that you are reporting a bug.
  • Ensure the issue isn't already reported.
  • Ensure you are reporting the bug in the correct repo.

Delete the above section and the instructions in the sections below before submitting

Package version

4.0.0

Node.js and npm version

5.6.0

Sample Code (to reproduce the issue)

Hello,
putting data in session impossible. I checked it's not big data.
Not giving any error.
Could you help me, please?
session.put('user-data', authResponse.body);
session.put('user-data2', "12345");//for this one not working

BONUS (a sample repo to reproduce the issue)

Error: RuntimeException: E_RUNTIME_ERROR: Session store is not initiated yet

Join a team to work on a Project. After setting up and installing everything, I try to run the server but keep getting this error.

UnhandledPromiseRejectionWarning: RuntimeException: E_RUNTIME_ERROR: Session store is not initiated yet. Make sure that you have included the session middleware inside the list of global middleware.

session ero

And the session is already included global middleware.

screenshot from 2018-12-22 09-17-56

I am using Nginx Proxy

OS

Ubuntu 18.04.1

Package version

"@adonisjs/session": "^1.0.28",

Node.js and npm version

Nodejs -- v10.14.2
npm -- 6.5.0

Flash message not working

I took flashMessage example from adonis docs for Version 4.1.
I am trying on localhost only with cookie based sessions but it is not showing flashmessage in view. Please help.

Controller

session.flash({ notification: 'Update successful!' })

View

@if(flashMessage('notification'))
<span>{{ flashMessage('notification') }}</span>
@endif

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.