Welcome Guest, Not a member yet? Register   Sign In
What exactly does the Codeignitor get_cookie() helper return?

The documentation is not clear on this.

Does it return an array or just the cookie value?

Did you try it?

[quote author="CoderReborn" date="1282084594"]The documentation is not clear on this.

Does it return an array or just the cookie value?[/quote]
It depends what value you set in the cookie!

[quote author="noctrum" date="1282085309"]Did you try it?[/quote]

The original poster brings up a valid point.

The doc says it returns false if the cookie is not found, but is not specific if the cookie is found.

On the flipside, if you look at, for example, the element() function in the array helper, the array storage/retrieval methods are clearly documented.

Obviously, if he's asking, he has not tried it yet.

And, for a website that boasts on its front page:
...clear, thorough documentation.

I don't think it was a far-fetched question to bring up here.

He was just looking for a friendly response...as was I.


FTR, it just returns the cookie value; which I presume is why the documentation does not go into detail.

[quote author="ray023" date="1283071883"]He was just looking for a friendly response...as was I.


And my point was that it takes less time to test the return value than it does to go to the forum, ask the question and wait for someone to reply (or, wait for someone else to test and then reply).

[quote author="noctrum" date="1283292909"]...it takes less time to test the return value than it does to go to the forum...[/quote]

Not necessarily. Had you answered the question, I would have had my answer immediately when I searched the forum and came across this thread.

Instead, you ask a rhetorical question that, IMHO, came off with an air of arrogance.

Please bear in mind, that some visitors to this site may not only be new to CI, but new to PHP and coding in general.

Or, on the flipside, maybe someone is wondering if the set/get cookie method did something a little more robust that the documentation did not cover.

The CI community has done such an outstanding job in documenting, that maybe it has somewhat spoiled its users with the mass amount of detail that's covered in this great framework. And I think that's why a question like the one above is a valid one.

Regardless, an informative reply to even a stupid question would be better than sarcastic one.

And that’s my point.

I'm not sure how "Did you try it?" comes across as arrogant, but that wasn't the intention. Sarcastic? Definitely. Had I written a longer post, it undoubtedly would have been more offensive.

The point stands especially for someone new to PHP or coding in general. You can't run here and have someone else solve your problems 100% of the time. Your first step should always be to try it first. Then, when it doesn't work, your second step should be to try to figure out why it didn't work. When you can't figure that out is when you should come here with what you tried, what you were expecting, and what happened. What I (and others here, I'd like to think) won't nurture is an attitude of "I'll just find someone else to do it for me", especially when you're asking a question that can be answered by writing one line of code:


There is value in a question like this for future users searching for an answer (like yourself), but this could have been much more constructive had it been "The documentation doesn't mention it, but I tested it and get_cookie() returns ____", and not "I can't be bothered to write one line of code, someone do it for me". I'll leave it at that.

I understand your point-of-view and applaud the manner in which you presented your argument.

FWIW, it was late and I had been staring at code and documentation for hours (not just cookie stuff). My dev environment wasn't in a state to test any new code and I just wanted a simple answer to my question to save some time. Thus, I searched the forum. If no related thread existed, I just would've signed off and said "I'll look into it tomorrow".

However, finding this thread and then seeing the sarcasm oozing out of the reply just rubbed me the wrong way. (ok...there! I admit it :-P )

But I get it; and I even appreciate the small snippet you put in the last post (yes...it's sad...I didn't know about var_dump).

Hopefully now, users with similar searches will get the info they're looking for.


P.S. if you ever do get a hankering to write a long, offensive post, please look at the user name first and make sure it's not me. I'm very sensitive.

Theme © iAndrew 2016 - Forum software by © MyBB