Basic Authentication

One of the earliest mechanisms for preserving client state is basic authentication. By state, I mean the current status of the user’s activity or transaction. Basic authentication is used to protect subdirectories of a Web server by user ID and password, and was implemented on some of the earliest Web servers. The only element of the session’s state that basic authentication maintains is the username and password they used to log in.

The way basic authentication works is that the server expects to receive an Authorization: header with requests. If the Authorization: header is not present or the user ID and password sent in the header are not valid, the request is rejected. The user sees a 401 Unauthorized response code, ...

Get Sams Teach Yourself CGI in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.