486 Part IV . Development Setting (Web site designers) and validating
486 Part IV . Development Setting and validating the cookie The following code contains two examples of the setcookie() function: setcookie( cookie_session , $id ,time()+60, / , ,0); setcookie( cookie_user , $encuser ,time()+60, / , ,0); print You have been successfully logged in
; The print statement at the end of this code snippet would be a good place to send a redirect to the client, sending it to another page or calling another function. Note In the first code snippet just given, normally you d put the valid URL for the cookie between the final double quotes to the left of the 0 in both instances. As it happens, some crazy redirection on my network prevents me from placing that value correctly (within that final set of quotes) for the example. The program to validate cookies is as follows: (unix_timestamp() - 600) AND md5(user) = $cookie_user ; $result = mysql_query($query) or die ( Query failed ); $num = mysql_num_rows($result); if ($num == 0) { print Session has expired
n ; exit; } else { $row = mysql_fetch_array($result); return $row[ auth_group ]; } } # End function check_session ?>
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.