New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
Web Design and Hosting Creating sites, scripting, and hosting discussions.

Cookie php code not working!


Post Reply New Thread Subscribe

 
Thread Tools
hojkoff_101

 
hojkoff_101's Avatar
 
Member Since: Oct 18, 2005
Location: Edinburgh Scotland
Posts: 225
hojkoff_101 is an unknown at this point
Mac Specs: Macbook 2.1GHz Intel Core 2 Duo, 4Gb RAM

hojkoff_101 is offline
Can someone tell me why this won't work? I can't understand why it won't install a cookie on my browser! I've tried Safari, Firefox and Opera and no luck on any of them!

PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Cookie</title>
</head>

<body>

<?php 

    setcookie
("test"45time()+(3600));
    echo 
"This page has loaded correctly! But is thy cookie there!";
    
?>
<br />
<a href="cookie_read.php">Check that cookie!</a>
</body>
</html>
The link is to a page which has been coded to show the value of the cookie but it doesn't display any value! When I check the cookies stored on my browser it isn't there either!

Any ideas as to why it's all going wrong!!!!!

Thanks guys!


Andy
QUOTE Thanks
BrandonSkyPim

 
Member Since: Feb 15, 2012
Posts: 3
BrandonSkyPim is on a distinguished road

BrandonSkyPim is offline
Same with me. And safari 4.0.3 does not support PHP
QUOTE Thanks
Groovetube

 
Groovetube's Avatar
 
Member Since: Nov 15, 2011
Location: Toronto
Posts: 290
Groovetube has a spectacular aura about
Mac Specs: Retina MBP 2.7 768ssd/16gig ram /30" dell 3008. and bunch of other mac/apple stuff

Groovetube is offline
you need to out the setcookie call above output or any html tags, whitespace etc. much the same kind of issues can affect this call like the header calls. It's sent with the html headers.

Take that setcookie line and put it up above everything, no whitespace.

ie:
PHP Code:
<?php setcookie("test"45time()+3600); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Cookie</title>
</head>

<body>
This page has loaded correctly! But is thy cookie there!
    <br />
<a href="cookie_read.php">Check that cookie!</a>
</body>
</html>
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 18,352
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
Quote:
Originally Posted by BrandonSkyPim View Post
Same with me. And safari 4.0.3 does not support PHP
Every browser "supports" PHP since it doesn't actually interact with PHP. PHP is a server side technology - all the heavy lifting is done on the server. It works by interpreting the code and returning the corresponding HTML. For instance, let's take the following PHP code:
Code:
echo "<div id='test'>Hello</div>";
When the page with that code is requested, the PHP interpreter is called on the server, it figures out that you want to echo out a div with some text and sends the following to your browser:
Code:
<div id='test'>Hello</div>

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks

Post Reply New Thread Subscribe


« iweb and audio player? | 1 url and 2 home pages? »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Validation code for Windows XP Shelbyw Running Windows (or anything else) on your Mac 5 02-01-2010 07:49 AM
Microsoft Office: Mac 2008 - product code Nienke OS X - Apps and Games 2 08-16-2008 03:35 PM
XCode Debugging From Source Code deanrayj OS X - Development and Darwin 0 04-25-2008 10:33 PM
DVD region code contradiction... NanoBite OS X - Operating System 10 11-07-2005 05:38 AM

All times are GMT -4. The time now is 06:22 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?