Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] cookies @ itch.io

Author
Message
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 24th Apr 2021 20:24 Edited at: 24th Apr 2021 22:32
i posted this at itch then thought to post here since it's AppGameKit (classic)-specific and figured someone might have already solved:
Quote: "
this jam game saves high scores on some machines and not others via a cookie. i expect it's a permission issue but i've added "itch.io" and the full game url to the whitelist on various browsers to no avail. any suggestions?

i get the same behavior on other html games i've published here, as well.

thanks for looking!
"
[My Itch.io Home] [Now Playing]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]

The author of this post has marked a post as an answer.

Go to answer

tboy
11
Years of Service
User Offline
Joined: 1st Jan 2013
Location: UK
Posted: 25th Apr 2021 02:59 Edited at: 25th Apr 2021 03:35
I believe this could be due to a Cross-site cookie issue, it appears that SameSite=None; Secure attribute is required now when setting cookies.

https://hacks.mozilla.org/2020/08/changes-to-samesite-cookie-behavior/

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite

https://web.dev/samesite-cookie-recipes/

Itch.io use an IFRAME so that could be causing the problem, to be honest, i've only just found out about this, so it's an interesting
issue you raised.

I tested your game via https://v6p9d9t4.ssl.hwcdn.net/html/2709328/index.html - without IFRAME

then tested;

https://virtual-nomad.itch.io/p3 - with IFRAME

The p3scores cookie was saved with values 5000|4000|3000|2000|1000 without issue without the IFRAME, but was not saved when the game is called from the IFRAME.

You should be able to enable this behaviour in most browsers. If you use Chrome, you can type in chrome://flags/ in the address bar and I think you enable SameSite by default cookies
and Cookies without SameSite must be secure

If you find out any other info, workarounds etc.. Please post back, I'd like to learn more about this.

I'm not sure if you can set it from javascript, but a possible solution could be something like this:

If you look in HTML5Core.cpp, you may be able to add SameSite=None; Secure to the end of document.cookie, then rebuild agktier2.



OR manually edit AGKPlayer.js and find:



Replace with:



I'm not so sure that will work.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 25th Apr 2021 06:31
running it "direct" via https://v6p9d9t4.ssl.hwcdn.net/html/2709328/index.html & it did save, as you said. and, searching "cookie" @ itch provided the same insight offered above.

meanwhile, i'm on Edge atm and whitelisting itch.io + 3rd party cookies + the same for hwcdn.net didn't resolve saves from within the iframe/at itch.io like i'd hoped. and, i can't see a SameSite setting anywhere but will continue the hunt!

thanks pointing me in the right direction, tboy.

[My Itch.io Home] [Now Playing]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
tboy
11
Years of Service
User Offline
Joined: 1st Jan 2013
Location: UK
Posted: 25th Apr 2021 14:43 Edited at: 25th Apr 2021 15:16
I've created a little test https://tvault.itch.io/test2 uses SameSite=None; Secure

and

https://tvault.itch.io/test3 not use SameSite=None; Secure

It creates a basic canvas with "Hello, World" and creates a highscores cookie set to 100

setting document.cookie = "highscores=100; SameSite=None; Secure"; seems to do the trick.



I've also set chrome://flags/ to defaults, so no special options have been set.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 25th Apr 2021 16:35 Edited at: 25th Apr 2021 16:36
is that something we can insert into the AGK-generated HTML file somewhere?


and, forgive my HTML ignorance but would:



not set highscores to 100 each time it loads?

and, i'm assuming we could access (variable name) "highscores" via Save/LoadSharedVariable ?

thanks agan.
[My Itch.io Home] [Now Playing]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
tboy
11
Years of Service
User Offline
Joined: 1st Jan 2013
Location: UK
Posted: 25th Apr 2021 20:16
It really needs to be changed in the main AppGameKit sourcecode so everyone can benefit from the changes.

If you consider HTML5Core.cpp in AGKTier2, you'll need to edit:



I know someone figured out how to run javascript code from their HTML5 project from Tier1, but as previously suggested it needs to be changed at the source.

If you're willing to provide me with your project media folder and bytecode.byc I could try and build a WebAssembly
version on my PI4 with the suggested changes and find out if it works.



Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 25th Apr 2021 20:45
Glad to provide the files when i return home in a day or 2.
[My Itch.io Home] [Now Playing]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 26th Apr 2021 22:31
Source now available. thanks for looking
[My Itch.io Home] [Now Playing]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
tboy
11
Years of Service
User Offline
Joined: 1st Jan 2013
Location: UK
Posted: 27th Apr 2021 21:41 Edited at: 27th Apr 2021 21:59
I've change HTML5Core.cpp to:



Adding SameSite=None Secure allows you to set and get the cookie on itch.io

Demo: https://tvault.itch.io/cookie

Tier2 code:


If you edit AGKPlayer.js and search for document.cookie=cookieName+"="+cookieValue+";"+expires+";path=/"

Change:

document.cookie=cookieName+"="+cookieValue+";"+expires+";path=/"

to

document.cookie=cookieName+"="+cookieValue+";"+expires+";path=/; SameSite=None; Secure"

It should solve your issue.
tboy
11
Years of Service
User Offline
Joined: 1st Jan 2013
Location: UK
Posted: 27th Apr 2021 23:07 Edited at: 27th Apr 2021 23:10
Your game:

https://tvault.itch.io/test-game

I can't get true type fonts displaying at the moment, there seems to be a problem with shooting bullets, triple shoot instead of single shot, but I will look into it.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 28th Apr 2021 03:31
Quote: " triple shoot"

i had updated the source "devlog" notes to advise that i had tinkered with the idea of power-ups after the jam so the triple shot is intentional (and easy enough to return back to single).

otherwise, with vanilla Classic/Studio, if i alter the .JS as mentioned above, it should work? or, do i have re-compile the player? IE, HTML5Core.cpp, (while i have 0 tier-2 experience).
[My Itch.io Home] [Now Playing]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
tboy
11
Years of Service
User Offline
Joined: 1st Jan 2013
Location: UK
Posted: 28th Apr 2021 06:46
Ah! That's fine then, I thought the triple shoot was an issue my-side, no problem.

I just thought if you change AGKPlayer.js with the suggested change it will get you up and running asap.

Edit the player that you uploaded with the game and see if it has the desired result.

On the Pi version, there is only one entry document.cookie=cookieName+"="+cookieValue+";"+expires+";path=/"

then change to:

document.cookie=cookieName+"="+cookieValue+";"+expires+";path=/; SameSite=None; Secure"





PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 30th Apr 2021 05:42
Did you get it working?

I once tried using a MySQL highscore table from itch.io but I think itch was blocking the request, it worked fine on desktop, mobile and my own server as soon as it went up to itch it stopped working
tboy
11
Years of Service
User Offline
Joined: 1st Jan 2013
Location: UK
Posted: 1st May 2021 12:30
The suggested change seems to work, I uploaded Virtual Nomad's game on my Itch.io page and the cookies saved via the IFRAME.

I've only tested on Chromium and Firefox.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 5th May 2021 20:42 Edited at: 7th Oct 2021 03:44
This post has been marked by the post author as the answer.
tboy wrote: "If you edit AGKPlayer.js, Change:"

document.cookie=cookieName+"="+cookieValue+";"+expires+";path=/"

to

document.cookie=cookieName+"="+cookieValue+";"+expires+";path=/; SameSite=None; Secure"

this does seem to have resolved the issue (tested on Edge). thanks, tboy!!
[My Itch.io Home] [AGK on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
hosch
Developer
3
Years of Service
User Offline
Joined: 25th May 2021
Location:
Posted: 13th Jul 2021 12:30
Sorry for bringing up this old thread again, I just wanted to say big thanks for the solution. Works like a charm!
Zaxxan
Developer
4
Years of Service
User Offline
Joined: 17th Nov 2020
Location: England
Posted: 6th Oct 2021 20:40
Thanks to tboy for posting this and thanks to Virtual Nomad for providing the link to this thread. I have used this to save the game statistics in my html5 games. I initially had a syntax error and had to delete the last quotation mark i.e

document.cookie=cookieName+"="+cookieValue+";"+expires+";path=/; SameSite=None; Secure""

to

document.cookie=cookieName+"="+cookieValue+";"+expires+";path=/; SameSite=None; Secure"
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 7th Oct 2021 03:41 Edited at: 7th Oct 2021 03:59
@zaxxan,

that last quote (") is from me quoting tboy. i removed the formatting so its a simple copy/paste line, now.

and, who do i have to pay to change their avatar to avoid confusion, for me. you or hosch?

that is, unless, you 2 are actually twins. then, i expect its something i'll have to contend with (forever)

either way, yall know you can attach an image to a post and then use that image URL in your Pofile's "Custom Avatar" field, right?

there are so many stock avs on the forum ATM... and, we're too creative for that!
[My Itch.io Home] [AGK on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
Zaxxan
Developer
4
Years of Service
User Offline
Joined: 17th Nov 2020
Location: England
Posted: 7th Oct 2021 05:20
I'll change mine, I never really liked it anyway! But I don't have one to upload at the moment so I'll change it to another stock one

Login to post a reply

Server time is: 2024-11-21 17:19:36
Your offset time is: 2024-11-21 17:19:36