Page 230 - Open Soource Technologies 304.indd
P. 230
Web Technologies-I
Notes Example allows the user to select text and background colours and stores those values in a
cookie. Any visits to the page within the next week send the colour values in the cookie.
Saving state across visits
<?php
if($_POST[‘bgcolor’])
{
setcookie (‘bgcolor’, $_POST[‘bgcolor’], time( ) + (60 * 60 * 24 * 7));
}
$bgcolor = empty($bgcolor) ? ‘gray’ : $bgcolor;
?>
<body bgcolor=”<? = $bgcolor?>”>
<form action=”<? = $PHP_SELF?>” method=”POST”>
<select name=”bgcolor”>
<option value=”gray”>Gray</option>
<option value=”white”>White</option>
<option value=”black”>Black</option>
<option value=”blue”>Blue</option>
<option value=”green”>Green</option>
<option value=”red”>Red</option>
</select>
<input type=”submit” />
</form>
</body>
Develop a PHP program to setting preferences with sessions.
9.7 Security Socket Layer(SSL)
SSL (Secure Sockets Layer) is the standard security technology for establishing an encrypted
link between a web server and a browser. This link ensures that all data passed between the
web server and browsers remain private and integral. SSL is an industry standard and is used
by millions of websites in the protection of their online transactions with their customers.
To be able to create an SSL connection a web server requires an SSL Certificate. When you
choose to activate SSL on your web server, you will be prompted to complete a number of
questions about the identity of your website and your company. Your web server then creates
two cryptographic keys—a Private Key and a Public Key.
The Public Key does not need to be secret and is placed into a Certificate Signing Request
(CSR) a data file also containing your details. You should then submit the CSR. During the SSL
224 LOVELY PROFESSIONAL UNIVERSITY