where are session properties (and their values) such as Browser, BrowserType, sessionPlatform, etc.?
These properties were removed because, if I remember correctly, it had become onerous to parse out each needed property from the User-Agent string. You can now access this data using the Session.RawHeaders method for search for your explicitly needed exceptions.
Here’s a quick and dirty method to add to your Session object to get the User-Agent string from the RawHeaders, it could be improved upon, but I just tossed it together to have something to show:
Public Function getUserAgent() as String
var headers() as String = self.RawHeaders.ReplaceLineEndings( EndOfLine ).ToArray( EndOfLine )
var searchField as String = "User-Agent"
var uaResult as String
for each line as String in headers
if line.NthField( ":", 1 ) = searchField then
uaResult = line.Middle( searchField.Length + 1, line.Length - (searchField.Length + 1) )
end if
next
Return uaResult
End Function
The reason they were removed are threefold:
- The data used to get them is notoriously unreliable these days. They can easily be spoofed and many browsers do just that.
- The Xojo framework was changed to be browser agnostic. That is, the appearance and functionality are essentially identical everywhere.
- Instead of making assumptions about functionality based on the user-agent strings, the framework now uses feature detection, that is, when the browser first connects, we run a series of tests to determine what features the browser actually has. It’s a much more reliable way of doing this and the info is available through the WebSDK.
Thanks for clarifying, Greg!
Sorry, how do I get these informations through WebSDK?
I’m feverishly working on finishing the docs with the intention of having them ready around the time that we ship 1.1.
I thought there was an easier way to get the user agent string? Am I misremembering? Should I make a ticket? I feel like the user agent string should be a simple session property.
ok. thank you.
I haven’t seen an easier method, though I’m also switching my code over to feature detection rather than user agents where I’ve previously incorporated that.
Session.Header("User-Agent")
Still we like to have the data for statistics to know what browser a visitor uses and what OS.
The code to detect was in Web 1.x and I bet you could copy it over to Web 2.
That code was a never ending battle. User agent strings would change subtly several times per year and our parser was never up to date.