Jump to content

php and cookies


snk

Recommended Posts

Hello,

 

I am going to make a quiz game solely with cookies. My problem is that I dont know how to set the cookie's variables on the submit procedure. I need to set the user's enter of a textbox (answer) and to transfer a value (score).

 

I set the cookie at the beginning as the php manual says. If I could use POST or GET I know how I was going to make it, but now there is restriction with only cookies and not post/get. Is there any Javascript piece of code that makes the magic? If yes could you give me an example or a link to?

 

thank you in advance.

Link to comment
Share on other sites

thanks for you replies.

 

I have to do it with cookies, it is restriction. I know how to set and retreieve the cookie. the problem is that I need to set it with the text's value, that means user has to enter a word and then the cookie sets the value.

 

any other suggestion?

Thanks again

Link to comment
Share on other sites

thanks for helping me,

 

the problem is... that I dont set the cookie when i submit the form. To understand what i want to do is to make a quiz. a user enters the answer, presses submit button and the next page shows if the answer is correct or not.

 

thanks again for your time.

Link to comment
Share on other sites

If i set the cookie before somebody submits the answer.... I will have a cookie with my value not with visitor's answer.

I want to pass the visitor's answer, the cookie has to set up dynamicaly.

 

So far you tell me to set a cookie before a visitor's answer.

 

I hope you see it now and give me a hand :)

 

 

Link to comment
Share on other sites

I know that sounds stupid... I know that I should send it via POST GET variables... But it is Coursework, so dont ask why... :P

Anyway I found the solution, you need javascript to do that. I will post later details, it is quite interesting.

Link to comment
Share on other sites

That tutorial isnt exactly accurate, this is not a true statement

 

You have to put the cookie code as the first line of your file, it has to be before the head, before any other code, HTML or PHP.

 

You can have PHP before the cookie and it will still work.

 

I have a login page that sets a cookie only if they choose to stay logged in.

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.