JQuery POST session != page session

85 views
Skip to first unread message

Adam Jack

unread,
May 23, 2019, 3:01:58 PM5/23/19
to Gorilla web toolkit
Please note I am a newb to Go lang, Go net/http and Gorilla Session, and somewhat to web development in general, and I suspect this is a newb question. I hope so, and hope you can point me in the right direction (without a lot of effort from you.) 

I am attempting to update a session within a server call that originates from a JavaScript JQuery POST within a page, however repeat/subsequent page calls get a different session (I suspect) from the one I updated (and saved.) I am using Chrome browser to test, and log.Printf to display values. My debugging log statements show a different session is generated each time for this call. (More precisely the %p print value of the struct is different, I'm not sure if I am off base with my assumption it is a different session.) Interestingly it does contain the values of the "page session", so maybe it is more my Save isn't saving.

Initially the session cookie was NOT sent on the JavaScript JQuery POST,  but I've resolved that using JQuery AJAX with xhrFields: {withCredentials: true}, ... however the session still appears to be different / "not saving".

As I continue to dig in with Chrome Developer tools (network tools) I do NOT see an updated cookie being sent back with the AJAX call.
Assuming I am storing sessions in the cookie itself (I'm using the CookieStore store implementation), is the fact that my save does not appear to update the cookie imply something wrong with the struct I saved into Values, or something?
Even if I should perhaps be using a different (file based) store, should I be seeing an updated cookie here?

I'm posting here 'cos I suspect folks new to Gorilla Session might've hit the same problem, and I'd appreciate pointers. Thanks in advance.

BTW: Unrelated but when I pass the session key from the environment and then failed to set it in the environment things failed silently. Should the NewCookieStore method reject an empty/missing string, maybe panic'ing? It would've saved me a lot of head scratching. :-)

regards,

Adam

Adam Jack

unread,
May 23, 2019, 4:29:24 PM5/23/19
to Gorilla web toolkit
Posting here (I'm sure it helped :-) ) then reading more postings here, helped my see there is an "error" response from session.Save, and checking it helped me find:
 

     securecookie: error - caused by: gob: type not registered for interface:


I'll work on that, but it seems a likely cause.

Thanks, and sorry for the noise.

Adam

Matt S

unread,
May 23, 2019, 4:32:01 PM5/23/19
to goril...@googlegroups.com
Hi Adam - could you open a GitHub issue for this? 

From a quick skim I suspect that your JavaScript doesn’t have access to your session cookie.

Post your session / store code when you open the issue.

Matt 

--
You received this message because you are subscribed to the Google Groups "Gorilla web toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gorilla-web...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gorilla-web/99b5700f-19a5-48b4-b5c0-05eb5cc880dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages