I've got a question which I have no idea how to go about except for 1 painful way..
Basically, I want to create an application which requires authentication. Okay, easy. However, I want to know the best way to have the application to remember that im authenticated, and be able to access properties, such as username, userid, groupID etc.. I know how to do something like this in PHP. Below is a code snippet to help people understand what im asking.
Is the best way to do this by adding another constructor which accepts userID as a parameter on all forms?
Expand|Select|Wrap|Line Numbers
- public Edit (int UserID)
Expand|Select|Wrap|Line Numbers
- <?php
- // Script1.php
- session_start();
- $_SESSION['authed'] = true;
- $_SESSION['uid'] = 1;
- $_SESSION['username'] = 'xenoix';
- ?>
Expand|Select|Wrap|Line Numbers
- <?php
- session_start();
- // script2.php
- if($_SESSION['authed'])
- {
- echo "Welcome, " . $_SESSION['username'];
- }