Jump to content

Archived

This topic is now archived and is closed to further replies.

habook2

Variable value in cookie

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Double Quotes.

Single quote represent literal text. So it will always print what is inbetween them, literally.

Share this post


Link to post
Share on other sites
[!--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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 translation

try this

setcookie ("lap", "$name", time() + 3600);

Share this post


Link to post
Share on other sites
[!--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...

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.