473,408 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Data Access Layers

15
Greetings all,

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
  1. public Edit (int UserID)
  2.  
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Script1.php
  3. session_start();
  4.  
  5. $_SESSION['authed'] = true;
  6. $_SESSION['uid'] = 1;
  7. $_SESSION['username'] = 'xenoix';
  8.  
  9. ?>
  10.  
then on another script:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. // script2.php
  4.  
  5. if($_SESSION['authed'])
  6. {
  7. echo "Welcome, " . $_SESSION['username'];
  8. }
  9.  
Thanks for any help provided.
Sep 1 '09 #1
4 1864
cloud255
427 Expert 256MB
Hi

.NET supports sessions pretty much the same way PHP does (judging from the code you posted)

Expand|Select|Wrap|Line Numbers
  1. Session.Add("auth", true);
  2. Session.Add("uid", 1);
  3.  
  4. if ((bool)Session["auth"])
  5. {
  6.     //true code here
  7. }
  8.  
Sep 1 '09 #2
xenoix
15
And this works with Visual C#? (I should have clarified that earlier..) Dont have VS installed atm to test..

If not, I think I can make another class and get/set values.
Sep 1 '09 #3
cloud255
427 Expert 256MB
@xenoix
Yes, the Session class is part of the .NET framework... But do note that this is specific to web form development, Session is not part of windows forms or WPF applications.
Sep 1 '09 #4
xenoix
15
Ah okay, yes my question was around Windows Forms :P

I think I worked it out though, just create a class called session or something and set parameters in that, and just request that on each page request.
Sep 1 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: sffan | last post by:
I am new to database programming and was curious how others solve the problem of storing encrypted in data in db table columns and then subsequently searching for these records. The particular...
0
by: sedefo | last post by:
I ran into this Microsoft Patterns & Practices Enterprise Library while i was researching how i can write a database independent data access layer. In my company we already use Data Access...
5
by: Kevin C | last post by:
I was curious to know what some developers out in the industry are doing when it comes to exposing Data access logic, specifically persistence. This is assuming that your not using an O/R framework...
41
by: laimis | last post by:
Hey guys, I just recently got introduced to data mappers (DTO mapper). So now I have a SqlHelper being used by DTOMapper and then business layer is using DTOMapper when it needs to persist...
2
by: headware | last post by:
I'm relatively new to ASP.NET and ADO.NET, but I have a basic design question regarding the use of web services and APS.NET applications. Right now we have an application that uses web services to...
3
by: Marc Castrechini | last post by:
First off this is a great reference for passing data between the Data Access and Business Layers:...
13
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those...
4
by: pratham | last post by:
Hi! I'm making a database application and i heard from a friend that it is more proffecional and easy to do this with bussines objects. Can anyone tell me where i can find more info on bussines...
3
by: kbutterly | last post by:
Good morning, I have seen two different types of data access layers and I am wondering which, if either, is considered best practice, or if one is better suited to certain situations than the...
7
by: =?Utf-8?B?U2F2dm91bGlkaXMgSW9yZGFuaXM=?= | last post by:
Why separate the Data Access Layer (DAL) methods from the Business Layer (BL)methods of an object ? Why not have them inside the object itself, since it's going to save its own data, using its own...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.