This may seem like a silly question but I am just starting out with dart and will need to verify user sesions similar to what you might do with PHP with the $_SESSION array...
So I am writing a basic server backend and a frontend and need to authenticate some requests that come in via XMLHttpRequest. The backend sends back JSON based on whether the given frontend is authenticated or not. In some cases, the frontend can update the DOM but only for the user who authenticated.
Not sure if I am explaining this well...
Any advice would be appreciated!!
Thanks!
A session is a high-level functionality that shouldn't be part of any language. You can include session functionality yourself by impelementing something like.
Map<String, int> sessions = {'abcdef12345' : 42}; // exists in e.g. datastore and is managed by an authentication routine
String authenticationToken = 'abcdef12345'; // comes from the request
if(sessions.containsKey(authenticationToken)) {
print('User ${sessions[authenticationToken]} is at least authenticated but might not have the appropriate rights to perform this operation.');
} else {
print('Not authenticated.');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With