Connecting Tech Pros Worldwide Forums | Help | Site Map

JS Cookie in PHP jigsaw puzzle game does NOT work.

tpgames's Avatar
Needs Regular Fix
 
Join Date: Jan 2007
Location: MN, USA - but rather be in UK
Posts: 356
#1: Mar 13 '07
I've tried to get a PHP cookie to work in php game, no luck.
I've tried to get a JS cookie to work. NO luck.
I can't even get a response in the php forum, so gave up!
I've posted 6 or 7 times and NO REPLY!
Am I tired? yes! All I wish is the stupid code for cookies to do something!

What do I want it to do? Save the page exactly how the user left it, so they can come back and finish the jigsaw puzzle at a later time.

What happens? I get a new puzzle.

So, where in the code needs to be changed so that the cookie will work?
I don't know. No one will even look at the silly program to let me know if the php code is preventing all cookies from working! It doesn't help that the file uses another file to 'chop' the images up. Thus, I have 2 php files that might be causing the issue.

To make matters worse, NO TUTORIAL even tells me whether I need to put the cookie on the frame page, the PHP page, or where on the php page, if thats the correct page.

Will a JS cookie overcome all coding issues with the php program to make the thing save the game in its current state of undoneness?
OR am I wasting my time, and should find a forum that only deals with PHP and nothing else ever.

Sorry for my frustration, but I've been asking since March 5th! (9 days ago).

Link to php.txt file to view code and what I've tried:
PHP TXT

Link to chop.txt file to view code:
CHOP TXT

Link to HTML file that pulls everything together:
HTML

ALL help is greatly and hugely appreciated! I do NOT understand cookies, even though I did read the tutorials. Sorry for my ignorance, but I'm just a little dense yet.
THANKS!

tpgames's Avatar
Needs Regular Fix
 
Join Date: Jan 2007
Location: MN, USA - but rather be in UK
Posts: 356
#2: Mar 13 '07

re: JS Cookie in PHP jigsaw puzzle game does NOT work.


EDIT: I should say that no tutorial tells me where to put a cookie when I am dealing with a jigsaw puzzle game with 2 PHP pages it could go on and a HTML page it could go on.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#3: Mar 14 '07

re: JS Cookie in PHP jigsaw puzzle game does NOT work.


First things first, you could start by naming your cookie functions in a more intuitive way instead of using some strange letters, but I think you've probably borrowed that script.

I think if you want to use cookies properly, use the scripts on PKK's website, see link. They're much easier to follow and understand.
tpgames's Avatar
Needs Regular Fix
 
Join Date: Jan 2007
Location: MN, USA - but rather be in UK
Posts: 356
#4: Mar 14 '07

re: JS Cookie in PHP jigsaw puzzle game does NOT work.


I did try the other code, and that doesn't work either. I'm confused. The 'read cookie' must actually do something, but I don't know what to put in the equation to make it save that page exactly as the user left it so that the user can go back and finish the jigsaw puzzle at a later time.

(I tried, in desperation, to use a cookie from the memory game that saves the high score, only because that cookie at least did something. However, I couldn't apply it the jigsaw puzzle game. That code just has 'zxc' in front of variable and all so that the JS will play nicely with other JS on the page. So, I just read the script without bothering with the zxc. Vic's scripts are the only scripts I don't have issues with when I put them with other scripts.)
tpgames's Avatar
Needs Regular Fix
 
Join Date: Jan 2007
Location: MN, USA - but rather be in UK
Posts: 356
#5: Mar 14 '07

re: JS Cookie in PHP jigsaw puzzle game does NOT work.


Just refresh the php txt page to see the NEW code with the new cookie code.Thanks!
tpgames's Avatar
Needs Regular Fix
 
Join Date: Jan 2007
Location: MN, USA - but rather be in UK
Posts: 356
#6: Mar 14 '07

re: JS Cookie in PHP jigsaw puzzle game does NOT work.


The problem is with the data I am trying to save is a
GAME IN PROGRESS, and not a high score.
Rather, I'm trying to save what jigsaw pieces are together, and which ones aren't. I'd like the User to be able to put in their name, and load the puzzle that they already have in progress.
Thanks!
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#7: Mar 14 '07

re: JS Cookie in PHP jigsaw puzzle game does NOT work.


You will need to store the variables that will reproduce the game. So how about setting the cookie for each move. Perhaps set the position of each piece on each move.
tpgames's Avatar
Needs Regular Fix
 
Join Date: Jan 2007
Location: MN, USA - but rather be in UK
Posts: 356
#8: Mar 15 '07

re: JS Cookie in PHP jigsaw puzzle game does NOT work.


Okay, that will mean that I'll have to table this question until I learn PHP better and JS. I'm not sure what part of the code does what in order to save movements. I'll do some reading first. :>)

Thanks!
(I won't be able to get to this until after April)
Reply