maintain such user on all web pages.
-
Hi All, I involved in developing a web project, I do login page to new users can registered on my web page. the problem how I can user maintain in all pages he navigate to. any help plz. Regards
As the others have mentioned, use session variables. Do make sure when you are done with the user's session variable to delete it when finished. Otherwise, you will eventually (as this may take a very long time to have happen) run out of memory on the server where the values are kept.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
Hi All, I involved in developing a web project, I do login page to new users can registered on my web page. the problem how I can user maintain in all pages he navigate to. any help plz. Regards
The one step no-one else mentioned, is to create a new base page, which redirects to the login page if the user is not already logged in. From there, it just works.
Christian Graus Driven to the arms of OSX by Vista.
-
The one step no-one else mentioned, is to create a new base page, which redirects to the login page if the user is not already logged in. From there, it just works.
Christian Graus Driven to the arms of OSX by Vista.
Good point.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
Good point.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
Would you believe I inherited a project that didn't bother to do this ? If you went to a URL inside the site directly, it would just work, or blow up on the basis of missing sessions variables ( not the login, all sorts of other stuff was being stored in the session and never checked when it was accessed ).
Christian Graus Driven to the arms of OSX by Vista.
-
Would you believe I inherited a project that didn't bother to do this ? If you went to a URL inside the site directly, it would just work, or blow up on the basis of missing sessions variables ( not the login, all sorts of other stuff was being stored in the session and never checked when it was accessed ).
Christian Graus Driven to the arms of OSX by Vista.
Christian Graus wrote:
I inherited a project that didn't bother to do this
Oh boy, I bet that was loads of joy fixing that up.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
Christian Graus wrote:
I inherited a project that didn't bother to do this
Oh boy, I bet that was loads of joy fixing that up.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
That was just one example, that whole site was a nightmare. The other big thing that blew my mind was that all session variables were strings, and all strings were typed in everywhere. I actually found code like this: if (Session["WeShouldDoStuffNow"] == "YES") when doing some searching proved that it was only ever set to Yes, or No. I obviously centralised all the 'WeShouldDoStuffNow' values to a class, so that there were never typos, but I gave up, I defined YES and NO rather than move to bools.
Christian Graus Driven to the arms of OSX by Vista.
-
That was just one example, that whole site was a nightmare. The other big thing that blew my mind was that all session variables were strings, and all strings were typed in everywhere. I actually found code like this: if (Session["WeShouldDoStuffNow"] == "YES") when doing some searching proved that it was only ever set to Yes, or No. I obviously centralised all the 'WeShouldDoStuffNow' values to a class, so that there were never typos, but I gave up, I defined YES and NO rather than move to bools.
Christian Graus Driven to the arms of OSX by Vista.
Christian Graus wrote:
session variables were strings, and all strings were typed in everywhere
Those can be a problem. Session variables are going to be a part of my discussion this up coming Tuesday evening in my VB.NET class I teach. I try to emphasize the importance of doing something like:
Dim MyUser As String = "UserName" If Session[MyUser] blah blah blah blah Then ....
is easier and safer to work with than having the variable name inside quotations. It is a point I try to get across, and usually get mixed mileage every semester.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
Christian Graus wrote:
session variables were strings, and all strings were typed in everywhere
Those can be a problem. Session variables are going to be a part of my discussion this up coming Tuesday evening in my VB.NET class I teach. I try to emphasize the importance of doing something like:
Dim MyUser As String = "UserName" If Session[MyUser] blah blah blah blah Then ....
is easier and safer to work with than having the variable name inside quotations. It is a point I try to get across, and usually get mixed mileage every semester.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
Yeah, I would create a class that contains all the strings, and use it throughout the site. It's hard to believe that anyone would fail to understand how important that is, once it's explained to them.
Christian Graus Driven to the arms of OSX by Vista.
-
Yeah, I would create a class that contains all the strings, and use it throughout the site. It's hard to believe that anyone would fail to understand how important that is, once it's explained to them.
Christian Graus Driven to the arms of OSX by Vista.
Christian Graus wrote:
would create a class that contains all the strings, and use it throughout the site.
Hmmmm, that sounds like a nice little final exam problem [evil grin]...
Christian Graus wrote:
It's hard to believe that anyone would fail to understand how important that is, once it's explained to them.
It happens from time to time, usually the student who is too busy IM'ing someone and not paying attention to the discussion. After they spend about two hours trying to debug the errors caused by the typos, it finally clicks.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
Christian Graus wrote:
would create a class that contains all the strings, and use it throughout the site.
Hmmmm, that sounds like a nice little final exam problem [evil grin]...
Christian Graus wrote:
It's hard to believe that anyone would fail to understand how important that is, once it's explained to them.
It happens from time to time, usually the student who is too busy IM'ing someone and not paying attention to the discussion. After they spend about two hours trying to debug the errors caused by the typos, it finally clicks.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
*grin* there's no teacher like experience, I guess.
Christian Graus Driven to the arms of OSX by Vista.