Jump to content

Recommended Posts

Posted

Greetings Everyone,

This is about cookies... The kind we set in our application!

Usually, I just use the native PHP function.  Simnple enough, and works reliably.  But with ProcessWire, I am always thinking about even more elegant ways for everything, and wanting to do what fits absolutely best with the $input in my favorite CMF.

Just wondering what others here like for cookies... Do you use PHP, Javascript, JQuery?

Thanks,

Matthew

Posted

In my last project i used jQuery to set cookies. But that was merely because its used for some GUI settings and other user-interaction.

I prefer jQuery / javascript above php because then you dont have to process the page server-side.

Posted

I prefer to bake them with integral flour and yellow sugar. My favorites have butter, almond or hazelnut, oat, cinnamon, and sometimes a bit of black pepper. I let them bake a lot until they get really crunchy.

Do you use PHP, Javascript, JQuery?

Hm, not sure if I ever tried those ingredients... are they tasty?

  • Like 3
Posted

For application-related cookies answer is "it depends on what you're building and for whom." Especially if it's purely UI related, non-critical stuff JavaScript is more than ok, but for anything more serious (where page loads are possibly happening anyway) PHP's setcookie() gets my vote. Then again, if you're working in an environment where JavaScript is required, it doesn't really matter -- whichever is easier to use :)

I've used jQuery cookie plugin once or twice, but the amount of "regular" JavaScript required for simple cookie getter / setter functions is so minimal that it's usually faster to write those functions locally and forget using plugins.

@diogo: black pepper, seriously? I'm obviously no cookie master, but that sounds strange -- though I could imagine baking some nice chili cookies myself.. :)

Posted

Greetings Everyone,

Thanks for the responses.

Usually, I don't give cookies much thought -- just do them.

I usually like to just use good old PHP, and it ties nicely into ProcessWire's $input function.  But I now have a project that calls for someone to click a button that sets a page as a kind of "favorite," at which time the button takes a different state, so I'm looking at JS/JQuery solutions.

It's a good opportunity to revisit an old thing.  I actually think I have been doing cookies the same way for like 8 years...

Thanks,

Matthew

PS: Please feel free to also share your favorite chocolate chip, peanut butter, or oatmeal recipes.

Posted

Why not just use $session? Of course, that's represented by a cookie behind the scenes, but the actual data stored in it remains server side and not manipulatable by the user. So it's safer than a cookie from that standpoint. Nearly the only time I use cookies is from Javascript/jQuery, as $session tends to accomplish anything I might use a cookie for on the PHP side. 

  • Like 1
Posted

Hey Ryan,

Thanks for jumping in.  I know, cookies and sessions fall along a continuum, and I agree that sessions have important advantages.

Plus, it seems that ProcessWire has more going on for sessions, which is another advantage.

Thanks again,

Matthew

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...