Jump to content


Photo

Variable value in cookie


  • Please log in to reply
5 replies to this topic

#1 habook2

habook2
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 17 June 2006 - 10:43 PM

I need to put the value of a variable in a cookie. I think it's:

setcookie ("cookiename", '$variable', time() + xxx time);

But that, when lookedup, contains the text "$variable". How do I put the variable's value in it instead?

#2 homchz

homchz
  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts
  • LocationLee, New Hampshire

Posted 17 June 2006 - 10:48 PM

Double Quotes.

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

#3 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 17 June 2006 - 10:50 PM

[!--quoteo(post=385130:date=Jun 17 2006, 05:48 PM:name=homchz)--][div class=\'quotetop\']QUOTE(homchz @ Jun 17 2006, 05:48 PM) View Post[/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.
[table]



Don't worry, the printer fairies will sort it out.

#4 habook2

habook2
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 17 June 2006 - 10:52 PM

The variable's not in double quotes, though. This is taken literally from the page:
setcookie ("lap", '$name', time() + 3600);

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.

#5 homchz

homchz
  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts
  • LocationLee, New Hampshire

Posted 17 June 2006 - 10:54 PM

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);


#6 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 17 June 2006 - 10:57 PM

[!--quoteo(post=385135:date=Jun 17 2006, 05:52 PM:name=habook2)--][div class=\'quotetop\']QUOTE(habook2 @ Jun 17 2006, 05:52 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
The variable's not in double quotes, though. This is taken literally from the page:
setcookie ("lap", '$name', time() + 3600);

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...
[table]



Don't worry, the printer fairies will sort it out.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users