Does server side Dart support sessions like in PHP:
<?php
session_start();
$_SESSION['fruit'] = 'apple';
The data is kept upon page loads.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes Dart has support for sessions which are more or less like in PHP.
Let’s write a simple program that randomizes a fruit between apples and bananas and saves the choice to the session.
Now when you run the code and go to
http://localhost, every time you see the same fruit as long as the session stays open, because we save the fruit to the session.Notes:
HttpRequestclass has this methodsession()which initializes (or returns) theHttpSessioninstance.HttpSessionhas a property calleddata, but you might want to initialize it first to be an empty{}.