Page 1 of 1

Question regarding logging into a website?

Posted: Fri Aug 17, 2012 1:02 pm
by mcc_shane
Hi Everyone,

I have a question regarding when a visitor tries to log into a website. For example, if a visitor tries to input a gas price (on the below site) and if they aren't logged in, my question is - how does the website know that visitor isn't logged in as a user yet?

If I clicked on "update" under any gasoline price the website automatically takes me to a login page, how does the website know how to do that?
http://www.newjerseygasprices.com/

Thanks everyone!

Re: Question regarding logging into a website?

Posted: Fri Aug 17, 2012 1:31 pm
by Christopher
It either stores a cookie in your browser that holds a value indicating whether you are logged-in, or it uses the session system that server languages have which identify unique users by their browser and IP information.

See the PHP manual: http://www.php.net/manual/en/features.sessions.php

Re: Question regarding logging into a website?

Posted: Fri Aug 17, 2012 1:35 pm
by califdon
This is done using what is called a "session variable" which is stored on the web server. It is often implemented using a small file stored on the visitor's computer, called a "cookie". Whenever a browser requests a web page, there is data exchanged between the browser and the server, including a very long number called the "sessionid", although this is normally never made visible to the user. But it is used in determining what is considered "a session". A session is ended when the user closes their browser or shuts down their computer, or it can be ended earlier, based on time. Look up "http session" on Google.