@
PCastagnetti
It seems that adding a filter that will monitor "/ws/*" is
NOT a good ideea after all, because this is an upgrade request so we need to set the session cookie before the upgrade request.
There are three problems that I found regarding Safari's problem with session cookie:
1. We need to have a session created before the upgrade request
2. Safari has a problem with localhost cookies (but i think this is not you case because you are connection from the ipad to the b4j server)
3. Safari has a problem with cookies that don't have the path set, so I checked the session cookie path that comes out of the server and is null, on Chrome it sets to "/" but I don't know if Safari does this also (I can't test because I don't have an Apple device)
So if we get rid of all this problems, maybe, just maybe we do not have to get the session at each request for a page but we need to get it once in the correct form - so we can use the filter (ABMSessionCreator) that monitors "/js/b4j_ws.min.js" which will be called only one time, just before the browser caches the file.
You can test and see if this works for you:
1. Replace the code from the Filter Sub in ABMSessionCreator with this one:
'if there is no cookie stored in browser we need to create one and set the cookie path to "/" also mark it as HttpOnly
If req.GetCookies.Length = 0 Then
Dim joCookie as JavaObject
joCookie.InitializeNewInstance("javax.servlet.http.Cookie", Array("JSESSIONID", req.GetSession.Id))
joCookie.RunMethod("setPath", Array("/"))
joCookie.RunMethod("setHttpOnly", Array(True))
'joCookie.RunMethod("setDomain", Array("www.yourdomain.com"))
resp.AddCookie(joCookie)
Log("Cookie created for session " & req.GetSession.Id)
End If
Return True
2. in ABMApplication, in StartServer you should have the ABMSessionCreator filter setup like this (like in the DemoDynamic):
srvr.AddFilter("/js/b4j_ws.min.js", "ABMSessionCreator", False)
You may have notice that one line from the Filter sub is commented. Try like this and see if it works, maybe is not needed to set the cookie domain!
Clear the cache from browser and access you application.
To see if the you get if have any cookies stored in the browser which are passed to the server you need to put a Log in WebSocket_Connected sub of every page:
Log("Your server session is " & ws.Session.Id)
Log("You have " & ws.UpgradeRequest.GetCookies.Length & " cookie(s)")
For i = 0 to ws.UpgradeRequest.GetCookies.Length - 1
If ws.UpgradeRequest.GetCookies(i).Name = "JSESSIONID" Then
Log("Your browser session is " & ws.UpgradeRequest.GetCookies(i).Value)
Exit
End If
Next
Please try this and post your result ...
Later Edit: you need to reference JavaObject library in your project.