GithubHelp home page GithubHelp logo

session-js's Introduction

Session-JS

Create a JS sessions like PHP sessions

Initialize Sessions

var session = new Session(); // default max-time: 3600 (30 minutes)

Pass max-time

var session = new Session(4800); // 1h20m

Insert session

session.set('user-id', 15); // Return session information. e.g. {'user-id': 15};

Get session

session.get('user-id'); // Return user-id from session. e.g. 15;

Get countdown time

session.countdown(); // e.g. 4799 (01:19:59)

Destroy session

session.destroy(); // destroy all session information

e.g.

<head>
    <title>Session JS</title>
</head>
<body>

    <p>Nome: <span id="nome"></span></p>
    <p>Usuário: <span id="user"></span></p>
    <p>Idade: <span id="age"></span></p>
    <p>Estado: <span id="state"></span></p>
    <p>Cidade: <span id="city"></span></p>

    <script type="text/javascript" src="session.js"></script>
    <script type="text/javascript" src="index.js"></script>

</body>

session-js's People

Contributors

littlecouto avatar

Watchers

 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.