Class is in Session…
So you have a great web application. Users are able to go to your website and truly enjoy the value of your website. But do you really know your users? Do your users know that you know who they are? It’s time to get personal.
It is second nature for web application to save information from their users and create more value from that information. One of the be ways to do that is through creating a log in or sign up page that takes in the user’s information. I am going to show you how to create a personal experience for those visiting your website and bring more value to your web application.
I am going to be using terminology of Ruby on Rails application so the assumption is that you are creating your app with Ruby on Rails platform.
I will create a session for my web application, JCourts so that my user will have a personal experience. JCourts is a project Jeff Bollings and I worked on for our Rails on Ruby learning. It currently does not have authentication, a way for our website to know who is viewing our website. So we are going to apply it to our application together.
First thing is set your routes for your signup and login pages. We will do these with restful routes. We will create a Welcome controller.
Create restful routes in for your Welcome controller to signup and login users.
Create a new method and create method in the Welcome controller. Once this is done create a new.html.erb template in your welcome/view folder. In this html file I will create my form for Sign up.
That creates this on my webpage…
Now it is time to create session controller. Session is going to put a restriction to different pages on the website unless user is signed up or logs in.
Create routes for your session. This will include a get request for the login and a post request.
In your session controller make sure you have the following code:
This is so your user id becomes the session’s id and therefore creates a personal experience.
Once you have that just make sure there is a link on the homepage to log out and that will destroy the session
There you go! You have created a personal experience for your users.
HAPPY CODING!!!