473,419 Members | 1,581 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,419 software developers and data experts.

Best way to check a session var on each page?

Jon
I am setting a session var upon login that holds some data about the user.
I need to check on every page to make sure the data is populated so if a
user bypasses the login page they are redirected to login first! I know on
each page load I can do a check of the session var and redirect if it's gone
or the wrong value, but I'd like a way to do it from one location. What's
the recommended method for this type of thing?

Thanks

--
********************************
Jon
Nov 19 '05 #1
5 2199
Probably the best is to use a base page which all your other pages inherit
from:

I was going to give you an example, but why retype what someone else already
has:
http://www.codeproject.com/aspnet/AspNetInheritance.asp

Hope that helps...
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Jon" <ru******@msn.com> wrote in message
news:10*************@corp.supernews.com...
I am setting a session var upon login that holds some data about the user.
I need to check on every page to make sure the data is populated so if a
user bypasses the login page they are redirected to login first! I know on each page load I can do a check of the session var and redirect if it's gone or the wrong value, but I'd like a way to do it from one location. What's
the recommended method for this type of thing?

Thanks

--
********************************
Jon

Nov 19 '05 #2
Jon,

Are you sure you are not duplicating the functionality already provided by
Forms authentication? If not, then do it in Application_AuthenticateRequest
method of your Global.asax.cs file.

:DG<

"Jon" <ru******@msn.com> wrote in message
news:10*************@corp.supernews.com...
I am setting a session var upon login that holds some data about the user.
I need to check on every page to make sure the data is populated so if a
user bypasses the login page they are redirected to login first! I know on
each page load I can do a check of the session var and redirect if it's
gone or the wrong value, but I'd like a way to do it from one location.
What's the recommended method for this type of thing?

Thanks

--
********************************
Jon

Nov 19 '05 #3
Jon
That'll work...Just one question, how do I convert this event adding
statement to VB.Net?
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uW**************@tk2msftngp13.phx.gbl...
Probably the best is to use a base page which all your other pages inherit
from:

I was going to give you an example, but why retype what someone else
already
has:
http://www.codeproject.com/aspnet/AspNetInheritance.asp

Hope that helps...
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Jon" <ru******@msn.com> wrote in message
news:10*************@corp.supernews.com...
I am setting a session var upon login that holds some data about the
user.
I need to check on every page to make sure the data is populated so if a
user bypasses the login page they are redirected to login first! I know

on
each page load I can do a check of the session var and redirect if it's

gone
or the wrong value, but I'd like a way to do it from one location.
What's
the recommended method for this type of thing?

Thanks

--
********************************
Jon


Nov 19 '05 #4
Jon
That'll work. One question, what is the equivalent of the following in
VB.Net?

base.Load +=new EventHandler(CommonPage_Load);

Thanks!
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uW**************@tk2msftngp13.phx.gbl...
Probably the best is to use a base page which all your other pages inherit
from:

I was going to give you an example, but why retype what someone else
already
has:
http://www.codeproject.com/aspnet/AspNetInheritance.asp

Hope that helps...
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Jon" <ru******@msn.com> wrote in message
news:10*************@corp.supernews.com...
I am setting a session var upon login that holds some data about the
user.
I need to check on every page to make sure the data is populated so if a
user bypasses the login page they are redirected to login first! I know

on
each page load I can do a check of the session var and redirect if it's

gone
or the wrong value, but I'd like a way to do it from one location.
What's
the recommended method for this type of thing?

Thanks

--
********************************
Jon


Nov 19 '05 #5
AddHandler myBase.Load, AddressOf CommonPage_Load

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Jon" <ru******@msn.com> wrote in message
news:10*************@corp.supernews.com...
That'll work. One question, what is the equivalent of the following in
VB.Net?

base.Load +=new EventHandler(CommonPage_Load);

Thanks!
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uW**************@tk2msftngp13.phx.gbl...
Probably the best is to use a base page which all your other pages inherit from:

I was going to give you an example, but why retype what someone else
already
has:
http://www.codeproject.com/aspnet/AspNetInheritance.asp

Hope that helps...
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Jon" <ru******@msn.com> wrote in message
news:10*************@corp.supernews.com...
I am setting a session var upon login that holds some data about the
user.
I need to check on every page to make sure the data is populated so if a user bypasses the login page they are redirected to login first! I
know on
each page load I can do a check of the session var and redirect if it's

gone
or the wrong value, but I'd like a way to do it from one location.
What's
the recommended method for this type of thing?

Thanks

--
********************************
Jon



Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Joshua Beall | last post by:
Hi All, What is the best way to use a cookie to remember a logged in user? Would you store the username and password in two separate cookies? Should the password be plain text? Hashed? Not...
27
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate...
6
by: Perdit | last post by:
My 1st page calls a 2nd that uses same data from a database. What is the best way to get the data in the second: a new call to the database or passing array through session variable?? I seems...
0
by: Tim T | last post by:
Hi, I have a web application that has a number of users who administer their own data... i have several pages that check to see if a valid userID session exists, and if not, send them to a...
3
by: Yul | last post by:
Hi, We are in the process of designing an ASP.NET app, where a user will enter some 'Customer ID' to be queried in the database. If the ID is valid, several stored procedures will be called to...
1
by: LilC | last post by:
I'm creating an application that has a standard layout for all pages. The information that is displayed in the layout will be dynamic based on the user that is logged in. Thus when a page is...
2
by: damian.jolly | last post by:
Is persisting objects to the SESSION the best way to prevent an object from being created every time a page is refreshed? It's a bit complicated but I'll try to be brief... I am using a guage...
11
by: john_c | last post by:
I'd like to store information for roles in Session variables. RoleA has a specific set of values, RoleB has a specific set and so one. When I access values for RoleA, it looks like this: ...
5
by: vajra1987 | last post by:
Hello everybody I am working on a Website built on JSP and Servlets . one of the features of the site is to give user the chance to subscribe to different newsletters under different categories. ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.