billyrudi Active Member Licensed User Longtime User Dec 23, 2015 #1 Hi i have problems with sessions variables with safari after upgrade to version 4. it seems that browser lose values. Chrome and firefox works correctly. In safari i have the accept cookies and data from all sites active. can anyone help me? Last edited: Dec 24, 2015
Hi i have problems with sessions variables with safari after upgrade to version 4. it seems that browser lose values. Chrome and firefox works correctly. In safari i have the accept cookies and data from all sites active. can anyone help me?
Erel B4X founder Staff member Licensed User Longtime User Dec 24, 2015 #2 billyrudi said: Hi Erel, Click to expand... Please don't limit your questions to a single member. This is a community forum. Upvote 0
billyrudi said: Hi Erel, Click to expand... Please don't limit your questions to a single member. This is a community forum.
Roberto P. Well-Known Member Licensed User Longtime User Dec 28, 2015 #3 I encountered the same problem also with iPad and iPhone. Upvote 0
billyrudi Active Member Licensed User Longtime User Dec 28, 2015 #4 Roberto, Domani ti giro la soluzione Upvote 0
Roberto P. Well-Known Member Licensed User Longtime User Dec 28, 2015 #5 Grazie mille. Buona serata Thanks you Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Dec 29, 2015 #6 I've tested the following code with an iPhone: Code: Copy Sub Class_Globals End Sub Public Sub Initialize End Sub Sub Handle(req As ServletRequest, resp As ServletResponse) Dim i As Int = req.GetSession.GetAttribute2("i", 0) req.GetSession.SetAttribute("i", i + 1) resp.Write(i) End Sub The number is incremented. Do you see a different behavior? Upvote 0
I've tested the following code with an iPhone: Code: Copy Sub Class_Globals End Sub Public Sub Initialize End Sub Sub Handle(req As ServletRequest, resp As ServletResponse) Dim i As Int = req.GetSession.GetAttribute2("i", 0) req.GetSession.SetAttribute("i", i + 1) resp.Write(i) End Sub The number is incremented. Do you see a different behavior?
billyrudi Active Member Licensed User Longtime User Dec 29, 2015 #7 hi, in safari and firefox i have problems with session.setattribute. i have success with Code: Copy WC.LocalStorage_SetItem( "TipoUtente", "paolo") and Code: Copy WC.LocalStorage_GetItem( "TipoUtente","null").Value where functions are Code: Copy Sub LocalStorage_SetItem(Key As String, Value As Object) mWS.Eval("$.jStorage.set(arguments[0], arguments[1]);", Array As Object(Key, Value)) End Sub Code: Copy Sub LocalStorage_GetItem(Key As String, Default As Object) As Future Return mWS.EvalWithResult("return $.jStorage.get(arguments[0], arguments[1]);", Array As Object(Key, Default)) End Sub i have a strangeness the jstorage.js must be lowercase. i have spent two days searching this solution. Upvote 0
hi, in safari and firefox i have problems with session.setattribute. i have success with Code: Copy WC.LocalStorage_SetItem( "TipoUtente", "paolo") and Code: Copy WC.LocalStorage_GetItem( "TipoUtente","null").Value where functions are Code: Copy Sub LocalStorage_SetItem(Key As String, Value As Object) mWS.Eval("$.jStorage.set(arguments[0], arguments[1]);", Array As Object(Key, Value)) End Sub Code: Copy Sub LocalStorage_GetItem(Key As String, Default As Object) As Future Return mWS.EvalWithResult("return $.jStorage.get(arguments[0], arguments[1]);", Array As Object(Key, Default)) End Sub i have a strangeness the jstorage.js must be lowercase. i have spent two days searching this solution.
billyrudi Active Member Licensed User Longtime User Dec 29, 2015 #8 Erel see your chat example in safari it doesn't works... Upvote 0
alwaysbusy Expert Licensed User Longtime User Dec 29, 2015 #9 Erel see your chat example in safari it doesn't works... Click to expand... Yes, that is the one I suspected it could go wrong. I think it happens when you move to another 'page' on your website. Pre 4.0 could do this, but 4.0 has some troubles saving the session vars. Unfortunately, ABMaterial relies a lot on this technique. Local storage was indeed also my alternative solution. Maybe it is the new jetty version that plays a role in it? Upvote 0
Erel see your chat example in safari it doesn't works... Click to expand... Yes, that is the one I suspected it could go wrong. I think it happens when you move to another 'page' on your website. Pre 4.0 could do this, but 4.0 has some troubles saving the session vars. Unfortunately, ABMaterial relies a lot on this technique. Local storage was indeed also my alternative solution. Maybe it is the new jetty version that plays a role in it?
Erel B4X founder Staff member Licensed User Longtime User Dec 29, 2015 #10 Try the online chat now. It should work (refresh the log-in page to make sure that the cache is invalidated). The workaround is to create the session and send the cookie before the upgrade request. This is done by adding this filter: Code: Copy srvr.AddFilter("/b4j_ws.js", "SessionCreator", False) The class code is: Code: Copy 'Return True to allow the request to proceed. Public Sub Filter(req As ServletRequest, resp As ServletResponse) As Boolean req.GetSession 'a new session will be created if a session doesn't exist. Return True End Sub Upvote 0
Try the online chat now. It should work (refresh the log-in page to make sure that the cache is invalidated). The workaround is to create the session and send the cookie before the upgrade request. This is done by adding this filter: Code: Copy srvr.AddFilter("/b4j_ws.js", "SessionCreator", False) The class code is: Code: Copy 'Return True to allow the request to proceed. Public Sub Filter(req As ServletRequest, resp As ServletResponse) As Boolean req.GetSession 'a new session will be created if a session doesn't exist. Return True End Sub
alwaysbusy Expert Licensed User Longtime User Dec 29, 2015 #11 Works perfectly on my iPad Erel, very elegant solution! For ABMaterial users: In ABMApplication add in ABMApplication in both StartServer and StartServerHTTP2: Code: Copy ' start the server srvr.Initialize(srvrName) srvr.AddFilter("/js/b4j_ws.js", "ABMSessionCreator", False) ' <----- Add this line srvr.AddWebSocket("/ws/" & AppName, "ABMApplication") ... Create a new Filter class ABMSessionCreator and add: Code: Copy 'Filter class Sub Class_Globals End Sub Public Sub Initialize End Sub 'Return True to allow the request to proceed. Public Sub Filter(req As ServletRequest, resp As ServletResponse) As Boolean req.GetSession 'a new session will be created if a session doesn't exist. Return True End Sub Upvote 0
Works perfectly on my iPad Erel, very elegant solution! For ABMaterial users: In ABMApplication add in ABMApplication in both StartServer and StartServerHTTP2: Code: Copy ' start the server srvr.Initialize(srvrName) srvr.AddFilter("/js/b4j_ws.js", "ABMSessionCreator", False) ' <----- Add this line srvr.AddWebSocket("/ws/" & AppName, "ABMApplication") ... Create a new Filter class ABMSessionCreator and add: Code: Copy 'Filter class Sub Class_Globals End Sub Public Sub Initialize End Sub 'Return True to allow the request to proceed. Public Sub Filter(req As ServletRequest, resp As ServletResponse) As Boolean req.GetSession 'a new session will be created if a session doesn't exist. Return True End Sub