Question regarding logging into a website?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mcc_shane
Forum Newbie
Posts: 22
Joined: Sat May 12, 2012 1:47 pm

Question regarding logging into a website?

Post 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!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Question regarding logging into a website?

Post 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
(#10850)
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Question regarding logging into a website?

Post 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.
Post Reply