habook2 Posted June 17, 2006 Share Posted June 17, 2006 I need to put the value of a variable in a cookie. I think it's:[code] setcookie ("cookiename", '$variable', time() + xxx time);[/code]But that, when lookedup, contains the text "$variable". How do I put the variable's value in it instead? Quote Link to comment https://forums.phpfreaks.com/topic/12268-variable-value-in-cookie/ Share on other sites More sharing options...
homchz Posted June 17, 2006 Share Posted June 17, 2006 Double Quotes. Single quote represent literal text. So it will always print what is inbetween them, literally. Quote Link to comment https://forums.phpfreaks.com/topic/12268-variable-value-in-cookie/#findComment-46817 Share on other sites More sharing options...
Fyorl Posted June 17, 2006 Share Posted June 17, 2006 [!--quoteo(post=385130:date=Jun 17 2006, 05:48 PM:name=homchz)--][div class=\'quotetop\']QUOTE(homchz @ Jun 17 2006, 05:48 PM) [snapback]385130[/snapback][/div][div class=\'quotemain\'][!--quotec--]Double Quotes. Single quote represent actual text. So it will always print what is inbetween them.[/quote]Ah if only you'd had a syntax highlighting text editor, would have spotted that one instantly. Quote Link to comment https://forums.phpfreaks.com/topic/12268-variable-value-in-cookie/#findComment-46820 Share on other sites More sharing options...
habook2 Posted June 17, 2006 Author Share Posted June 17, 2006 The variable's not in double quotes, though. This is taken literally from the page:[code] setcookie ("lap", '$name', time() + 3600);[/code]That's exactly how it's in the page, but when the coolkie is echoed from another page, it actually says "$name".Also, since I'm broke, I use notepad. Works for HTML pretty well, but not so much with PHP. Quote Link to comment https://forums.phpfreaks.com/topic/12268-variable-value-in-cookie/#findComment-46822 Share on other sites More sharing options...
homchz Posted June 17, 2006 Share Posted June 17, 2006 You need it to be in double quotes is what I am trying to say. Single quotes are for literal translation, you do not want literal translationtry this setcookie ("lap", "$name", time() + 3600); Quote Link to comment https://forums.phpfreaks.com/topic/12268-variable-value-in-cookie/#findComment-46824 Share on other sites More sharing options...
Fyorl Posted June 17, 2006 Share Posted June 17, 2006 [!--quoteo(post=385135:date=Jun 17 2006, 05:52 PM:name=habook2)--][div class=\'quotetop\']QUOTE(habook2 @ Jun 17 2006, 05:52 PM) [snapback]385135[/snapback][/div][div class=\'quotemain\'][!--quotec--]The variable's not in double quotes, though. This is taken literally from the page:[code] setcookie ("lap", '$name', time() + 3600);[/code]That's exactly how it's in the page, but when the coolkie is echoed from another page, it actually says "$name".Also, since I'm broke, I use notepad. Works for HTML pretty well, but not so much with PHP.[/quote]What!? You don't have to pay for syntax highlighting text editors! Just google it, there are a few good ones around for Windows. I use Linux though which is a free operating system and all the programs on it are completely free. It also comes with a text editor called Kate which is a joy to code with. It uses really sophisticated syntax highlighting and supports hundreds of languages as well keeping your tabs which is invaluable. Pity there's not a Windows version I know of, you could compile it from source I guess... Quote Link to comment https://forums.phpfreaks.com/topic/12268-variable-value-in-cookie/#findComment-46825 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.