NetTalk Central

Author Topic: Multiple SessionID session variables in my cookies?  (Read 9354 times)

patrick de laet

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • ShopPlus
    • Email
Multiple SessionID session variables in my cookies?
« on: December 16, 2011, 10:56:38 AM »
NetTalk 4.43.

I have problems Setting and Getting values from my SessionQueue.
When I check my cookies, I find out that I have 6,7, even 9 SESSIONID cookies for my website?
Everytime I refresh my page, I get a new SessionID.

I'm using File Name Redirection as explained in the NetTalk book.
I'm using the _SendFilemethod in the WebHandler procedure.
I only have 1 page: www.xprodin.be/index.html, but in the _SendFile embed I'll change the pagename to www.xprodin.be/trousers/ladies or www.xprodin.be/trousers/men, ...
It seems as a SessionID cookie is created for every page?

See screenshots here:
www.shopplus.be/clip12.png
www.shopplus.be/clip13.png
www.shopplus.be/clip14.png

regards

Patrick De Laet



Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Multiple SessionID session variables in my cookies?
« Reply #1 on: December 16, 2011, 08:39:52 PM »
how do you see that cookie list?
Also, if you look in the server log, how many cookies come though with each request?

cheers
Bruce

patrick de laet

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • ShopPlus
    • Email
Re: Multiple SessionID session variables in my cookies?
« Reply #2 on: December 17, 2011, 12:56:15 AM »
In the server log, I see from time to time the following:
SESSIONID=12345678, SESSIONID=854245678, SESSIONID=1285415678, SESSIONID=1788515678, ...

But I'm accessing my website via Port 88 ==> www.xprodin.be:88
And I'm using a <base href="http://www.xprodin.be:88/"/> statement in my HTML HEAD

I changed both to www.xprodin.be (default port 80) and now it seems to work.

Are those cookies created per web URL?
Maybe there something wrong when having the port at the end? (:88) and he thinks that www.xprodin.be:88/trousers/ladies or www.xprodin.be:88/trousers/men, ...are different web sites?

regards

Patrick De Laet





patrick de laet

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • ShopPlus
    • Email
Re: Multiple SessionID session variables in my cookies?
« Reply #3 on: December 17, 2011, 12:57:52 AM »
Sorry Bruce - forgot to answer your question on how I see these cookie lists.

You can see them in Firefox and Google Chrome, ...

regards

Patrick De Laet



Johan van Zyl

  • Full Member
  • ***
  • Posts: 180
  • jvz
    • View Profile
    • Email
Re: Multiple SessionID session variables in my cookies?
« Reply #4 on: December 17, 2011, 02:27:27 AM »
http://www.xprodin.be was written in NTWS? All of it?
Johan van Zyl
Clarion 6.3 9058/C8 Gold/SQL/NetTalk WebServer

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Multiple SessionID session variables in my cookies?
« Reply #5 on: December 17, 2011, 03:50:54 AM »
Hi Patrick,

>> In the server log, I see from time to time the following:
SESSIONID=12345678, SESSIONID=854245678, SESSIONID=1285415678, SESSIONID=1788515678, ...

I've not seen that before, but you're on a really old build so I wouldn't like to say what is and isn't possible.

>> Are those cookies created per web URL?
no.

>> Sorry Bruce - forgot to answer your question on how I see these cookie lists.
>> You can see them in Firefox and Google Chrome, ...

yeah, that much was obvious from your screenshots. But you've still not told me _how_.

cheers
Bruce

patrick de laet

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • ShopPlus
    • Email
Re: Multiple SessionID session variables in my cookies?
« Reply #6 on: December 18, 2011, 01:52:19 PM »
at: Johan Van Zyl

http://www.xprodin.be was written in NTWS? All of it?

Yes, all NetTalk WS (and JQuery)

But i've handcoded all HTML and CSS and I'm just using NetwebPage (for my AJAX) request and NetWebSource for some "widgets" like the shopping cart.
Those widgets are wired together by handcoding html and css and some Javascript.

regards

Patrick De Laet

patrick de laet

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • ShopPlus
    • Email
Re: Multiple SessionID session variables in my cookies?
« Reply #7 on: December 25, 2011, 01:15:42 AM »
I still have a lot of different SESSIONID cookies for my single site www.xprodin.be

Further investigation brought me to the following:

In the SendFile embed of the WebHandler procedure, I'm changing the filename of the page to load.
When I'm doing this, I have a different SESSIONID cookie for every page loaded (HTML, CSS, even GIF files have a different SESSIONID cookie). (see screenshots hereafter)
When I put my code in comment, so I doesn't change the filename, I only have 1 SESSIONID cookie.

_SendFile embed:
    message('self.sessionID=' & self.SessionID)

    Fetch_Level(p_FileName)

    !---
    !--- language onafhankelijke pagina's
    !---
    Case lower(loc:filename)
      Of 'index.html'
        self.SetValue('page', loc:filename)
        self.SetValue('switch', 'welkom')
        do SetValues
        loc:filename = 'index1.html'
        Parent._SendFile(loc:filename, p_header)
        Return

      Of 'admin.html'
        self.SetValue('page', loc:filename)
        self.SetValue('switch', 'admin')
        do SetValues
        loc:filename = 'index2.html'
        Parent._SendFile(loc:filename, p_header)
        Return

The message('self.sessionID=' & self.SessionID) popups a lot of different SESSIONID cookies - see screenshot www.shopplus.be/clip1.png

When I don't change the filename - everything is OK - www.shopplus.be/clip5.png

In Firebug you see all the different SESSIONID cookies:

www.shopplus.be/clip2.png
www.shopplus.be/clip3.png
www.shopplus.be/clip4.png

What I'm I doing wrong?

regards

Patrick De Laet





patrick de laet

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • ShopPlus
    • Email
Re: Multiple SessionID session variables in my cookies?
« Reply #8 on: December 25, 2011, 03:29:47 AM »
I'm closing in on the problem (at least I think  >:( ) - see also my previous post.

When loading my page, the webserver is serving a lot of files in parallel. (see screenshot clip7.png hereafter)
However, the first file is the largest and takes half a second.
In the meantime, 10 other files are server to my Firefox browser.
What i see now is that in the first (large) file, there is a Set-Cookie for the SESSIONID in the HTML header.
But the other, smaller files, are served before my large file and all these small files also do a Set-Cookie SESSIONID in the HTML header. (see screenshot clip6.png hereafter)
So 10 smaller files arrives before the big file arrives at the browser. All these small files do a Set-Cookie with 10 different SESSIONIDS.
Once the big file is completely served, all the following smaller files don't do a Set-Cookie SESSIONID.

All this only happens when I do file redirecting in the _SendFile embed

www.shopplus.be/clip7.png
www.shopplus.be/clip6.png

regards

Patrick

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Multiple SessionID session variables in my cookies?
« Reply #9 on: December 26, 2011, 07:58:20 PM »
You still haven't told me where to see that cookies list in FireFox - for some reason I'm being blind and I can't find it.

Of course your explanation makes perfect sense. But tell me, if (after these files have all been served) - if you make another request - how many cookies appear in the log, on the Cookies part of the request?

my guess is that there's really only one cookie in play.

cheers
Bruce

patrick de laet

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • ShopPlus
    • Email
Re: Multiple SessionID session variables in my cookies?
« Reply #10 on: December 27, 2011, 12:38:39 AM »
Bruce,

You can see the cookies in FireFox as follows: Tools - Options - Privacy
Then change "remember history" droplist to "Use custom settings for history"
There you can view your cookies, remove cookies, ...
screenshot ==> www.shopplus.be/clip20.png

I've upgraded to Nettalk 5.45 but still a lot of cookies.

You can view it yourself:
1. remove all your cookies in Firefox
2. load this page: http://www.xprodin.be/nl/vragen2.html
3. In Firebug (Net) you see that at least 6 new SESSION cookies (Set_Cookie) are created.
4. Hit F5 refresh a few times and check the Cookies

See screenshots hereafter.
Apparently, a new SESSION cookie is created for every subdirectory when serving files.
eg:
www.xprodin.be/vragen2.html ==> Set_Cookie
www.xprodin.be/assets/image1.gif  ==> Set_Cookie
www.xprodin.be/assets/image2.gif  ==> NO Set_Cookie
www.xprodin.be/assets/image3.gif  ==> NO Set_Cookie
www.xprodin.be/css/screen.css  ==> Set_Cookie
www.xprodin.be/css/print.css  ==> NO Set_Cookie

screenshots:
www.shopplus.be/clip21.png
www.shopplus.be/clip22.png

And I get a lot of DELSESSIONS in my Webserver trace.

www.shopplus.be/clip23.png

I'm only using NetWebPage and NetwebSource - all handcoding - no NetWebBrowse or NetWebForm

I really don't know where to look :-(
For a moment I was convinced that it was my file redirection in the _SendFile embed, but even without this embed a lot of SESSIONID cookies are created.

I really need a single cookie because I'm doing a lot of AJAX calls and these calls don't work without a valid cookie.

regards

Patrick De Laet



Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Multiple SessionID session variables in my cookies?
« Reply #11 on: December 27, 2011, 05:53:43 AM »
Hi Patrick,

cool - I can see the cookies now in my firefox, but what's interesting is that your effect is different to what I'm seeing with an example app.
Even though I'm fetching multiple files, at startup, from multiple folders (.js, .css and so on) only one cookie is being sent to the browser.

Now it's possible that cookie is sent with multiple values - because the browser requests are asynchronous, but that in itself is no big deal - the browser sees them as a "update cookie" and there's still only one cookie in the cookie jar. (this is what I see with an example).

What's interesting is that your cookies have a "path" assigned to them, whereas the cookies in the example don't seem to have that.

so the question becomes - are you calling the SetCookie method yourself?
the only times I call it are in the netweb.clw module and none of those calls include a "path" parameter.
(aside, the source for setcookie is in the nethttp.clw module.) The SetCookie parameter can take a path parameter, but I'm never using that internally.

So I'm guessing that maybe you're calling SetCookie yourself?

Or - if not - can you duplicate the effect in an example?

cheers
Bruce




patrick de laet

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • ShopPlus
    • Email
Re: Multiple SessionID session variables in my cookies?
« Reply #12 on: December 27, 2011, 10:04:37 AM »
Bruce,

So I'm guessing that maybe you're calling SetCookie yourself?
>> no, I'm not calling SetCookie myself.

Or - if not - can you duplicate the effect in an example?
>> I'll give it a try, but I've compiled the NetTalk example 1 just to display http://www.xprodin.be/nl/vragen2.html as a static page. And it also creates multiple Cookies.. So - just 1 static page - with example 1 - and I have the problem.

regards

Patrick De Laet

bruce2

  • Full Member
  • ***
  • Posts: 108
    • View Profile
    • Email
Re: Multiple SessionID session variables in my cookies?
« Reply #13 on: December 27, 2011, 10:49:54 PM »
excellent! - can you email me (or post here) a zip of your modified example 1 please?

patrick de laet

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • ShopPlus
    • Email
Re: Multiple SessionID session variables in my cookies?
« Reply #14 on: December 28, 2011, 12:43:26 AM »
Bruce,

You can download a zip file here: www.shopplus.be/$bruce.zip

It contains:
1. the example web1.app - I didn't modify anything in it - I just use it to show my static HTML page.
2. a "web" folder with the html page and some subdirs for the css, scripts,assets, ..
3. 2 screenshots showing the duplicate SESSIONID cookies in Firefox.

To test:
1. delete all your cookies from Firefox
2. display the page http://localhost:88/nl/vragen2.html
3. display your cookies from Firefox
4. if not duplicates, hit a few times F5 (refresh)
5. display your cookies from Firefox

regards

Patrick De Laet