Jump to content

Add info to cookie outside of headers


br3nn4n

Recommended Posts

Okay, so (sorry I'm only just learning about how PHP works with cookies) I can add to the cookie once it's SET, right?

 

IE: use setcookie() at the beginning of the file (before the HTML headers are sent, I think?) to set the cookie and then add to and retrieve from it later. Yes?

 

Once the cookie is set in the user's browser, it can then be added to can't it?

 

Sorry for all the questions but my poll is gonna be REALLY skewed unless I set some cookies to prevent voting more than once from the same IP.

Link to comment
Share on other sites

You could possibly require them to log in, and use both cookies and sessions to prevent a skewed graph.

 

Sorry if you've thought of that, but just putting it out there.

 

And yes I'm not quite sure but I think once you set the cookie you can retrieve from it later.

And yes you can add more to it once it's set.

Link to comment
Share on other sites

Once the cookie is set in the user's browser, it can then be added to can't it?

 

Ever thought of trying it?

 

I'm just trying to get a complete grasp over it before I spend any time on it really, so I don't just waste that time.

 

I tried putting it right after the <html> tag but that gave the standard "Warning: Cannot modify header information" error. I just tried putting it before the <html> tag as well and that did the same thing.

Link to comment
Share on other sites

BAM! stupid whitespace, I got it working. Placed it absolutely first, and took out the space after the <?php

 

Okay, so as I understand it the cookie is now there, and that can be verified by using the javascript:alert(document.cookie) command. Now, last thing, where do I go from here? I use the setcookie() function but what do I put inside it?

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.