PHP in html files

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
jaymoore_299
Forum Contributor
Posts: 128
Joined: Wed May 11, 2005 6:40 pm
Contact:

PHP in html files

Post by jaymoore_299 »

Code: Select all

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
</style>


<?php
$url="COOKIES";
setcookie ("visitor_", "", time()-3600); 
setcookie ('visitor_', $url, time() + (60*60*24),'/','.abcde.com');
?>

</head>
<body>
</body>
</html>
This is in a file cookie.html . When I run this I don't see any cookie made for my domain (ex: abcde) or with www in front of it. When I put just the php code in a php file and run that then the cookie is made fine.
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

Post by spamyboy »

are you sure that PHP scripts works in HTML files :)?
sheila
Forum Commoner
Posts: 98
Joined: Mon Sep 05, 2005 9:52 pm
Location: Texas

Post by sheila »

And cookies need to be set before any output to the browser, i.e., before any HTML is printed.
Post Reply