Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3747

Having Trouble with Cookies - Migrating from Web1.0 to 2.0

$
0
0

I’m migrating a Web1.0 app and having trouble with Web2.0 and cookies. I have a socket on a login page that raises a custom event after a user successfully logs in that contains oauth2 values. In Web1.0 the following code worked to set/save browser cookies but does not in Web2.0 (2023r4 or 2024r1):

Sub Oauth2_Authentication_Results(access_token As String = "", expires_in As Integer = - 1, token_type As String = "", scope As String = "", refreshToken As String = "", httpStatus As Integer = - 1) Handles Oauth2_Authentication_Results
  
  var loginSession As Session = app.SessionForControl(self)
  //var webSessContext As New WebSessionContext(loginSession)
  
  
  //loginSession.Cookies.set("test","test")
  
  if loginSession <> nil and httpStatus = 200 and access_token <> "" then
    
    #If DebugBuild then
      loginSession.Cookies.Set("userdata", access_token, DateTime.Now.AddInterval(0,0,1))
    #else
      loginSession.Cookies.Set("userdata", access_token, DateTime.Now.AddInterval(0,0,1), "", "", true, true)
    #Endif
    
    
    loginSession.accessToken = access_token
    
    loginSession.expiresIn = expires_in
    
    loginSession.tokenType = token_type
    
    loginSession.scope = scope
    
    loginSession.refreshToken = refreshToken
    
    GetUserScope()
    
    
  else
    
    MessageBox("Login Failed")
    
  end if
  
  
  
  
  Exception e As NilObjectException
    MessageBox(e.Message)
End Sub

The code never breaks on an error and stepping through the code it seems to work, but the cookie is never set. Not even the simple commented out test cookie works.

Using: Session.Cookies.set("test","test") in the login page’s opening event does work. So I’m somehow not getting the correct session anymore. I’m not sure what changed between Web1.0 and Web2.0 regarding sessions.

Any help is appreciated. :grinning:

4 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 3747

Trending Articles