Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Biology Forums on December 29, 2018, 12:58:08 PM

Title: Cookie Storage Question
Post by: Biology Forums on December 29, 2018, 12:58:08 PM
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?
Title: Re: Cookie Storage Question
Post by: Arantor on December 29, 2018, 12:58:59 PM
What, exactly, are you doing with setcookie?
Title: Re: Cookie Storage Question
Post by: Biology Forums on December 29, 2018, 01:25:53 PM
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.
Title: Re: Cookie Storage Question
Post by: Biology Forums on December 29, 2018, 01:30:21 PM
I think I just answered my own question. Once the cookie is made, set it to whatever

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

Ha
Title: Re: Cookie Storage Question
Post by: Arantor on December 29, 2018, 01:30:33 PM
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
Title: Re: Cookie Storage Question
Post by: Biology Forums on December 29, 2018, 01:31:54 PM
^^ thanks man!