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

How to build a web application the right way

I am looking into building a web application and one of the things I
want to do is to make sure the user is logged in. I know I can do this
by checking the session for a user object or something similar. Is
there a best practice for this. Currently what I do is have each page
include a check session include file.

Dec 28 '06 #1
8 1394
I struggled with this too. I wanted my customer, the owner of the
webpage, to have the ability to run utilities to maintain his page's
database but prevent anyone from even accidentally running any of the
PHP utility scripts. It was more challenging considering the owner
might run these utilities from anywhere, like a public internet cafe.

I could have used a login and password but that can be picked up
enroute since we were not using https. I finally decided to display a
simple, random puzzle that only the customer knew how to solve. If the
answer he typed matched the answer sitting on the server, a session key
was set and he was free to use any of the utilities until he closed the
browser. Anyone coming along and perhaps reviewing the URL history
(e.g., http://www....com/deleterecord.php?id=101) would get an error
message if they tried to run them.

Write me for details.

Anthony Smith wrote:
I am looking into building a web application and one of the things I
want to do is to make sure the user is logged in. I know I can do this
by checking the session for a user object or something similar. Is
there a best practice for this. Currently what I do is have each page
include a check session include file.
Dec 29 '06 #2
Anthony Smith wrote:
I am looking into building a web application and one of the things I
want to do is to make sure the user is logged in. I know I can do this
by checking the session for a user object or something similar. Is
there a best practice for this. Currently what I do is have each page
include a check session include file.
Yep, that's what I do.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Dec 29 '06 #3
On 28 Dec 2006 12:06:53 -0800, "Anthony Smith" <mr******@hotmail.com>
wrote:
>there a best practice for this. Currently what I do is have each page
include a check session include file.
From what I read, this is how it should be done. Put the check in a
file, and include it first thing in all the pages.
Dec 29 '06 #4


On Dec 29, 6:26 am, Vincent Delporte <just...@acme.comwrote:
On 28 Dec 2006 12:06:53 -0800, "Anthony Smith" <mrsmi...@hotmail.com>
wrote:
there a best practice for this. Currently what I do is have each page
include a check session include file. From what I read, this is how it should be done. Put the check in a
file, and include it first thing in all the pages.
And to take it to the next step you include thier remode address as
part of thier session check (md5 with ip and user name or something to
mix it up) so if someone were to intercept your session and try to take
over, the change in client IP (during the session) would void the
access.

And other thing would be to put a time limit to the current session
access ( a session var with expiration time) so if some badguy got in
from a user abandoning a terminal with a live connection it would time
out regardless. (or/also maybe have a re-verification for
sensitive/delete/admin parts just to make sure) Just depends on how
paranoid you want to be.

Dec 29 '06 #5
la***@portcommodore.com wrote:
>
On Dec 29, 6:26 am, Vincent Delporte <just...@acme.comwrote:
>>On 28 Dec 2006 12:06:53 -0800, "Anthony Smith" <mrsmi...@hotmail.com>
wrote:

>>>there a best practice for this. Currently what I do is have each page
include a check session include file. From what I read, this is how it should be done. Put the check in a

file, and include it first thing in all the pages.


And to take it to the next step you include thier remode address as
part of thier session check (md5 with ip and user name or something to
mix it up) so if someone were to intercept your session and try to take
over, the change in client IP (during the session) would void the
access.
VERY BAD IDEA!

First of all, there are providers like AOL who have multiple servers.
Every time a user accesses the page they may come in on a different IP
address.

And many companies have one server for the entire company (or at least a
site). Anyone coming into your site would be coming from the same IP
address. Since the two most likely places to intercept the packets are
on either end of the link and you know your server's end is secure (or
at least hope it is), this provides no protection whatsoever. Worse, it
bugs some users while providing a false sense of security for others.
And other thing would be to put a time limit to the current session
access ( a session var with expiration time) so if some badguy got in
from a user abandoning a terminal with a live connection it would time
out regardless. (or/also maybe have a re-verification for
sensitive/delete/admin parts just to make sure) Just depends on how
paranoid you want to be.
This is a good idea. But then if someone stupidly leaves a computer
signed on in a public place, there is a limit to how much you can do
without hassling all of the other users of your site.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Dec 30 '06 #6

Jerry Stuckle wrote:
>
VERY BAD IDEA!

First of all, there are providers like AOL who have multiple servers.
Every time a user accesses the page they may come in on a different IP
address.

And many companies have one server for the entire company (or at least a
site). Anyone coming into your site would be coming from the same IP
address. Since the two most likely places to intercept the packets are
on either end of the link and you know your server's end is secure (or
at least hope it is), this provides no protection whatsoever. Worse, it
bugs some users while providing a false sense of security for others.
Interesting I didn't realize that the IP address could change for some
users in the middle of a session; thanks (I had got the tip from
another page a while back guess it wasn't that great of a resource.)

I guess there isn't a good verification methgod of "you are still you"
without user intervention then?
And other thing would be to put a time limit to the current session
access ( a session var with expiration time) so if some badguy got in
from a user abandoning a terminal with a live connection it would time
out regardless. (or/also maybe have a re-verification for
sensitive/delete/admin parts just to make sure) Just depends on how
paranoid you want to be.

This is a good idea. But then if someone stupidly leaves a computer
signed on in a public place, there is a limit to how much you can do
without hassling all of the other users of your site.
It depends on the data or value of lost/damaged data I guess. The best
solution would be to educate the end user, but sometimes it's not as
easy.

Dec 30 '06 #7

Anthony Smith wrote:
I am looking into building a web application and one of the things I
want to do is to make sure the user is logged in. I know I can do this
by checking the session for a user object or something similar. Is
there a best practice for this. Currently what I do is have each page
include a check session include file.
There are many "best practices" for securing your webaps. And their is
a ton of argument as to which is the best of them all. The solution
you pick is going to depend greatly on whether or not you decide to use
a database of some kind (MySQL, or even a flat flat file db). I use a
database solution for all my sites and follow this sort of algorithm:

function check_login() {
get auth_string from session variable
if auth_string is not null {
validate auth_string, check for SQL injection
SELECT COUNT(*) FROM users_table
WHERE $auth_string = MD5(CONCAT(username, auth_key))
if count == 1 return true
}
get username, password from post variable
validate username and password, check for SQL injection
SELECT COUNT(*) FROM users_table
WHERE username=$username AND password=$password
if count == 1 {
generate a new auth_key
update user record with auth_key
set session variable to MD5(username + auth_key)
return true
}

return false
}

For generating the new auth key, I just use a random string or letters
and numbers, there are a ton of algorithms out there for that, or you
could just use a time string or something.

Now you would do this on every page you wanted under your login:

if check_login() show page
else show login form
That may not be the best solution, you may also want to implement some
form of time out to it as well, but for my purposes it works good. You
can feel free to email me if you have questions about it.

Dec 30 '06 #8
Anthony Smith wrote:
by checking the session for a user object or something similar. Is
That's how I do this. You may as well check some MVC frameworks with
session and auth management support and look how it's done there.
--
Mateusz Papiernik, Maticomp Webdesign
ma**@maticomp.net, http://www.maticomp.net
"One man can make a difference" - Wilton Knight
Dec 30 '06 #9

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

Similar topics

8
by: tmb | last post by:
1 - Can you build an entire web page or site with Java... sorta like you can with Flash? 2 - Can you do... .. Drag & Drop .. Push Buttons .. Hot Spot .. Hot Object .. Pull Down's (combo...
9
by: deko | last post by:
I'm confused about what I can use C# and VS.NET for. I have both Visual Studio 6.0 and Visual Studio .NET - which one do I use? If I want to build a basic VB app, I assume I can use the VB 6...
10
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a...
1
by: lester | last post by:
I'm using a C++ dll and need to allow unsafe code because the dll function takes char *. I am using Visual Studio.NET 2002. Everything I've seen says to go to the project properties page, then the...
7
by: kackson | last post by:
Hi. Each time I right click on an exe file, say Acrobat.exe, and look at the properties page, I could see information such as company name, version and build number, etc. of the application. How...
3
by: Christopher Baldwin | last post by:
Hello, Using ASP.NET v2.0.40607.42, I'm attempting to create a new file extension that should be handled exactly like "aspx" pages. For example, I just want to rename an aspx page from...
1
by: AlexZh | last post by:
Hi, I'd like to stop command line build by one project build failed. To do that I've created simple AddIn (see code below), that works fine for IDE and does not work for command line. In the AddIn...
4
by: Janet | last post by:
Hi, I've converted my project from VS 2003 to VS 2005. But when I try to build the web project, there are no DLL files inside the bin folder. I've tried to create a new Class library project...
10
by: Mo | last post by:
Hi, I am trying to write a code to build a string 768 characters long. This string is going to be written to a file which is then read by another application. The format of the string is already...
28
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I am developing C++ COM native code (unmanaged C++) using Visual Studio 2005. I do not take any new features of 64-bit platform, and currently my code runs fine on 32-bit...
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
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
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
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.