Code Monkey home page Code Monkey logo

express-session-with-redis's Introduction

Express Session with Redis

This repository contains sample code on how to use Redis for a cookie-based session implementation with Redis and the Node.js express framework.

Please help this repo with a โญ๏ธ if you find it useful! ๐Ÿ˜

This repository is part of the Sessions in express.js tutorial series on YouTube provided by productioncoder.com.

Express sessions with redis

For updates, please reach out to @_jgoebel on Twitter.

Session implementation with express.js and express-session

This repository illustrates how to create a session-based authentication system in Express.js and what configurations you need to perform for you server to also accept cookies from cross origins - a scenario that is typical for Single Page Applications (SPAs) written in modern frameworks such as React or Vue.

Running this project

1. Installing Redis

Make sure that you have Redis running locally on your machine on its default port 6379.

This project assumes that your Redis instance does not require a password (which is the default).

If your local Redis requires a password, please update the db/redis.js file to include the password field:

const redisClient = redis.createClient({
    port: 6379,
    host: 'localhost',
    password: 'your-password'
});

If you are on macOS, the easiest way to start up a Redis instance is by using Homebrew

brew install redis
brew services start redis

To stop Redis, you can run

brew services  stop redis

2. Install dependencies

Run:

npm install

to install the project's dependencies.

3. Start server

Execute the dev script to start up your server.

npm run dev

express-session-with-redis's People

Contributors

jangbl 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

Watchers

 avatar  avatar

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.