Giter Site home page Giter Site logo

sinatra-basic-sessions-lab-onl01-seng-ft-072720's Introduction

Sinatra Basic Sessions Lab

Session cookies allow a website to keep track of your movements and information from page to page for a single session (log in time to log out time). As soon as you log out, the cookie expires and the browser loses the data.

Server side, you set up a session, and the information from that session is stored in the browser by way of a cookie.

The goal of this lab is to save a piece of data to the session cookie, and display that data in a view.

Sessions are commonly used to store data for online shopping. In this lab, you'll be storing an item a user is buying from page to page.

Instructions

You'll be coding your solution in both app.rb and views.

  1. Make sure you enable sessions in app.rb and set a session_secret.

  2. Set up a controller action that responds to a GET request to the route '/'. You'll want this action to render an erb file, index.erb.

  3. index.erb should contain a form with text field. Here, the user will enter an item to purchase. The form should post to the action /checkout.

  4. The controller action /checkout, should take the params from the form and add it to the session hash. The key should be item and the value should be the item the user entered to the purchase. Make sure to store the session hash in an instance variable that you can access in the views.

  5. In the view rendered by the controller action, display the item the user entered to purchase.

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

sinatra-basic-sessions-lab-onl01-seng-ft-072720's People

Contributors

victhevenot avatar annjohn avatar aviflombaum avatar jmburges avatar maxwellbenton avatar thebrianemory avatar pletcher avatar sophiedebenedetto avatar

Watchers

Kaitlin Vignali avatar Mohawk Greene avatar  avatar Otha avatar raza jafri avatar  avatar Joe Cardarelli avatar The Learn Team avatar  avatar Ben Oren avatar Matt avatar Alex Griffith avatar  avatar Amanda D'Avria avatar  avatar Ahmed avatar Nicole Kroese  avatar Dominique De León avatar  avatar Vicki Aubin avatar  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.