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

Sessions, Cookies or both?

cassbiz
202 100+
I am almost finished with a script and currently all users are using a preset user and pass. Currently I am using sessions but I want guests to be able to come to the site without using a user and pass for the general public pages.

What is the best recommendation?

The software is for campground and B and B reservations.
Dec 18 '06 #1
10 1524
b1randon
171 Expert 100+
I am almost finished with a script and currently all users are using a preset user and pass. Currently I am using sessions but I want guests to be able to come to the site without using a user and pass for the general public pages.

What is the best recommendation?

The software is for campground and B and B reservations.
Save yourself some hassle and build an abstract class that every page inherits. Build your security into the abstract that way every page automatically checks security UNLESS the inheriting class overrides. This will save you from accidentally letting people get into pages here and there because you forgot to apply to the security.
Dec 18 '06 #2
vssp
268 100+
Cookies - stored in your system permenently .

session - stord the value global once close the browser session value expired
Dec 19 '06 #3
ronverdonk
4,258 Expert 4TB
I agree with b1randon: it is better to do this in a more structured way then just 'hopping' between cookies and session variables.

b1randon: can you also suggest an approach towards a solution?

Ronald :cool:
Dec 19 '06 #4
cassbiz
202 100+
Hey b1randon,

That sounds good. Can you give me an example or throw a tutorial to me so that I can read up on it?

The more PHP I write the more I realize that I don't know very much :)

Thanks in advance.



--treasure hunting - a sure way of going broke--
Dec 19 '06 #5
b1randon
171 Expert 100+
Hey b1randon,

That sounds good. Can you give me an example or throw a tutorial to me so that I can read up on it?

The more PHP I write the more I realize that I don't know very much :)

Thanks in advance.



--treasure hunting - a sure way of going broke--
Just make a "page" object that automatically runs a method which checks security. Then make an object like "welcomePage" that extends "page". If you want everyone to have access just overload the method with a stub that doesn't do anything. I don't have a tutorial for ya man. Sorry. I learned the approach in Java and just applied it to PHP. Anyone else have one?
Dec 19 '06 #6
cassbiz
202 100+
Just make a "page" object that automatically runs a method which checks security. Then make an object like "welcomePage" that extends "page". If you want everyone to have access just overload the method with a stub that doesn't do anything. I don't have a tutorial for ya man. Sorry. I learned the approach in Java and just applied it to PHP. Anyone else have one?

Hey b1randon, is it possible that you throw me an example. I understand the concept of what your saying but don't have a clue the process for implementation.
Dec 20 '06 #7
b1randon
171 Expert 100+
Hey b1randon, is it possible that you throw me an example. I understand the concept of what your saying but don't have a clue the process for implementation.
Oh gosh.. ok.. I don't have access to PHP right now and writing this kind of thing is rather lengthy so excuse the mistakes and brevity but here's the basics:

base class:
[PHP]
class Page {
var $content = "";
function write() {
echo $this->content;
}

function security(){
var $auth = check here();
if (!auth)
die("unauthorized");
}

//this guy here is the constructor
function Page(){
//these functions will be run when you instantiate the class
$this->security();
//if security didn't die it'll write
$this->write();
}
}
[/PHP]
here's a given page unsecured:
[PHP]
class WelcomePage extends Page {
var $content = "Welcome!";
function security() {
//Overloaded so everyone gets in!
}
}
[/PHP]
here's a secure one:
[PHP]
class SecurePage extends Page {
var $content = "Welcome to the secured page!";
//security was checked b/c parent security method was run
}
[/PHP]
Again, no access to PHP so I know that needs to be cleaned up and implemented and stuff, but that should illustrate the concept for ya.
Dec 20 '06 #8
cassbiz
202 100+
Thanks I will give it a try.
Dec 22 '06 #9
AricC
1,892 Expert 1GB
I wouldn't mind seeing a complete example if you guys piece one together. I'm thinking about learning PHP.
Dec 22 '06 #10
ronverdonk
4,258 Expert 4TB
How very wise, AricC! DHTML, JavaScript and PHP make a great combo!

Ronald :cool:
Dec 22 '06 #11

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

Similar topics

3
by: Kevin Thorpe | last post by:
I've hit a problem with sessions. If I have a document relying on sessions which has a link target=_blank then the new window inherits the session from its parent (in IE). However, if I embed...
10
by: Marcus | last post by:
Hi All, First, just wanted to say that I found what I thought was a very helpful tutorial on sessions in case anyone out there has questions on them: ...
1
by: windandwaves | last post by:
Hi Gurus I am basically sorry that I have to bother you about this. I am a PHP beginner and I have been studying sessions and cookies over the last few weeks. I have learned lots, but I am...
10
by: Mark H | last post by:
Hey all-- I'm building a database and I basically need to keep out people who aren't authorized, but it's not like I need top security here. I'm just doing basic user/pass of a SQL database, and...
11
by: Ohaya | last post by:
Hi, I'm trying to understand a situation where ASP seems to be "blocking" of "queuing" requests. This is on a Win2K Advanced Server, with IIS5. I've seen some posts (e.g.,...
1
by: AnthonyC | last post by:
I am having a problem tracking down what I believe to be a problem with the way cookies are being used on our website application. When user log onto the application, an in-memory (per-session)...
5
by: jheines | last post by:
I am trying to explain how cookies and sessions work in a class I teach, but I have hit a wall when it comes to the interaction between cookies and the state of the privacy settings in Internet...
8
by: Chuck Anderson | last post by:
I've instituted a sessions based scheme on my web site to combat hot linking to my images. When someone requests a page at my site, I set a session variable. I then use htaccess to redirect *all*...
7
by: pek | last post by:
OK, I've been having this problem for quite some time but never until now I really needed a solution. I have never thought of a work around, so I really need your help. Sorry if this has been...
11
by: rsbgm | last post by:
Dear All, Ok. Here I am again for some answers. I've gotten to understand more of things from here than other places. I hope I don't get spoiled. LOLZ... Associative Array is an array that...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.