Sams Teach Yourself HTML, CSS & JavaScript Web Publishing in One Hour a Day

(singke) #1
ptg16476052

Other Application Platforms 683

24


Cookies and Sessions


Cookies are a browser feature that lets websites set values that are stored by your browser
and returned to the server any time you request a page. For example, when users log in
to your site, you can set a cookie on their computers to keep track of who they are so that
you don’t have to force them to log in any time they want to see a password-protected
page. You can also use cookies to keep track of when visitors return to your site after
their initial visit. PHP provides full support for cookies. It also provides a facility called
sessions. Sessions enable you to store data between requests to the server. For example,
you could read a user’s profile into her session when that user logs in to the site, and then
reference it on every page without going back and loading it all over again. Generally,
cookies are used with sessions so that the server can keep track of which session is asso-
ciated with a particular user.


File Uploads


Back in Lesson 12 you learned about file upload fields for forms. PHP can deal with file
uploads, enabling the programmer to access and manipulate them. With PHP, file uploads
are stored to a temporary location on the server, and it’s up to the programmer to decide
whether to store them permanently and, if so, where to put them.


Other Application Platforms


PHP is just one of many programming languages that people use to write web applica-
tions. It is the language used to create popular web applications like Drupal, WordPress,
and Expression Engine. It’s also the tool used by major web companies like Facebook
and Yahoo! However, other options are available. If you’re just diving into web program-
ming yourself, PHP is probably a good choice, but you might find yourself working on
applications written in another language. Here’s a brief overview of the languages you
may encounter.


Microsoft ASP.NET


Microsoft provides the ASP.NET environment for writing web applications that run on
Windows servers. ASP.NET is similar to PHP in that it supports embedding server-side
code in HTML pages. It supports Visual Basic and C# as programming languages, and it
runs on Microsoft’s Internet Information Server, which is included with Windows Server.
You can read more about ASP.NET and download free tools for developing and running
ASP.NET applications at http://www.asp.net/.

Free download pdf