News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Cookie Storage Question

Started by Biology Forums, December 29, 2018, 12:58:08 PM

Previous topic - Next topic

Biology Forums

I've been using the PHP setcookie function lately. When I call the cookie to see if it's set or not, I either get 0 or 1. Was curious if I could store more than just binary in a cookie, and if so, how?

Arantor

What, exactly, are you doing with setcookie?
Holder of controversial views, all of which my own.


Biology Forums

Let's say I want to set the cookie $_COOKIE['XYZ'] = 'Hey, Hello!'. (Curious if that's even possible)

setcookie('XYZ', 0, $expiration);

Currently, I only know how to set the cookie name, XYZ, along with an expiration date.

It's a general question, not directed towards a specific SMF process.

Biology Forums

I think I just answered my own question. Once the cookie is made, set it to whatever

$_COOKIE['XYZ'] = 'Hey, Hello!'

Ha

Arantor

The reason you get 0 back is because that's what you're telling PHP to set as the cookie in the first place...

setcookie('XYZ', 'Hey, Hello!', $expiration);

Reference: http://php.net/setcookie
Holder of controversial views, all of which my own.



Advertisement: