Code Monkey home page Code Monkey logo

hs-sinatra-sessions's Introduction

tags languages resources
sinatra, sessions
ruby
1

Sinatra Sessions

Today we're going to be learning all about sessions and how they work!

Instructions

  • Clone this repository down to your local directory.
  • Type in bundle install in your terminal
  • Run shotgun and follow along in your browser.
  • Follow along in the README
  • As you go through each exercise, type in learn to ensure that your tests pass (you can quit shotgun, or run learn in a different terminal window)

Introduction to Sessions

The Hyper-Text Transfer Protocol (HTTP) is, by definition, a stateless protocol. The reason why it's called a stateless protocol is because a server does not attach special meaning to a request, and consequently does not require the server to retain any information about a user or entity for the duration of a request.

So how does a web application maintain state for a user? It can do this via cookie-based sessions, where a cookie is stored on the client-side (in the browser) and used to warehouse data related to activity in the current user's session.

Introduction to the Lab

This is a simple lab that will go through the basic implementation of a session in Sinatra. Be sure to read the specs to see what's required of each step.

First Exercise

A session cookie is simply a text file that consists of key-value pairs. In a web application, a session cookie is represented by a hash that is called session. So, for example, if we have a key in our sessions hash that is called "happiness", and we set it equal to the number 3.14, it will look like this:

{
  'happiness' => 3.14
}

We can access this ID attribute via session[:happiness] or session['happiness'].

In our first exercise, we will navigate to the /first_exercise path. Please follow instructions for each step, and be sure to run rspec before implementing each step. Make each test pass before proceeding to the next step.

Second Exercise

In our second exercise, we will navigate to the /second_exercise path. As in the previous lesson, be sure to run rspec before implementing each step. Make each test pass before proceeding to the next step.

Resources

View Sinatra Sessions on Learn.co and start learning to code for free.

hs-sinatra-sessions's People

Contributors

fislabstest avatar ipc103 avatar irmiller22 avatar msuzoagu avatar sarogers avatar stephaniecoleman avatar victhevenot avatar

Watchers

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

Forkers

rubycourse

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.