Re: another easy cookie question - SOLVED

From: Date: Fri, 21 Sep 2001 15:04:33 +0000
Subject: Re: another easy cookie question - SOLVED
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-68161@lists.php.net to get a copy of this message
Hi all, I solved my Cookie problem by making it simple: On cookietest.php I have: <? setcookie("Cookievalue", "abcdefghijklmnopqrstuvwxyz0123456789", time()+3600); ?> and on cookietest.lasso I have Display Cookie: [Cookie:'Cookievalue']<p> and the cookie is displayed properly. This will allow me to integrate Lasso and PHP together and be able to pass data between them using cookies. I am already using PHP to download PDF files in a Lasso solution. If and when I become proficient, I'll rebuild my solution in php. It's using a 12-db Filemaker system as the database and I don't really want to change that as its just soooo easy for the clients to use. Thanks for everyone's suggestions. George, in Edinburgh ----- Original Message ----- From: "Richard Baskett" <rickbaskett@home.com> To: "PHP General" <php-general@lists.php.net> Sent: Friday, September 14, 2001 7:04 PM Subject: Re: [PHP] another easy cookie question > The way I see it is that your script never has a chance to set the cookie > plus you can not send headers after html, one other thing is that you have a > ")" at the end of your setcookie function value so if you reformatted it > this way: > > <? > setcookie("Cookievalue", "abcdefghijklmnopqrstuvwxyz0123456789", > time()+3600); > header("Location: index.php"); > exit; > ?> > > <html> > <head> > <title>Untitled Document</title> > <meta http-equiv="Content-Type" content="text/html; > charset=iso-8859-1"> > </head> > > What that will do is as soon as it comes to the page it will set a cookie > and then take you to index.php. You do not need to use the full URL in the > Location. Plus I have had nothing but trouble with the setcookie function > so I just send the header setcookie instead, for example I use this code: > > header("Set-Cookie: $CookieName=$CookieValue; path=/; expires=$expireDate"); > > Make sure expire is in this format and it'll work on all browsers: > > $expireDate = gmdate("l, d-M-"); > $expireDate .= gmdate("Y")+1; > $expireDate .= gmdate(" H:i:s")." GMT"; > > this sets the expiration date for one year. > > All in all your new code would look like: > > <? > $expireDate = gmdate("l, d-M-"); > $expireDate .= gmdate("Y")+1; > $expireDate .= gmdate(" H:i:s")." GMT"; > header("Set-Cookie: $CookieName=$CookieValue; path=/; expires=$expireDate"); > header("Location: index.php"); > exit; > ?> > > <html> > <head> > <title>Untitled Document</title> > <meta http-equiv="Content-Type" content="text/html; > charset=iso-8859-1"> > </head> > > > > <html> > > <head> > > <?php > > header("Location:index.php"); > > setcookie("Cookievalue", "abcdefghijklmnopqrstuvwxyz0123456789") > > time()+3600); > > ?> > > <title>Untitled Document</title> > > <meta http-equiv="Content-Type" content="text/html; > > charset=iso-8859-1"> > > </head> > > > > I get the following error. > > > > CGI Error > > The specified CGI application misbehaved by not returning a complete set > of > > HTTP headers. The headers it did return are: > > > > ... and nothing else! > > > > Where am I going wrong? I bet it's a simple answer. > > > > George P in Edinburgh > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com

« previous php.general (#68161) next »