# NOTE: the value of the following array is pulled
# from a field in a table (to determine what the user
# has access to/is a member of. The first number is the database/subdomain
# it's located on, the second number is the ID number of the area and coincidentally
# the ID # of the folder the site is contained within, under the subdomain.
my @userCanAccess = (1:2, 1:3, 2:6, 2:9, 1:10);
my $dbh = DBI->connect("DBI:mysql:dbname:localhost","username","pw");
foreach my $i (@userCanAccess) {
my ($sub, $area) = (split /:/, $i);
my $dbName; # dbName is the same as the name as the subdomain
if ($sub == 1) { $dbName = 'db1'; }
elsif ($sub == 2) { $dbName = 'db2'; }
elsif ($sub == 3) { $dbName = 'db3'; }
elsif ($sub == 4) { $dbName = 'db4'; };
my $statement = "SELECT folderName, accessLevel, userID, otherColumn
FROM $dbName.areas
WHERE areaID = ?";
my $sth = $dbh->prepare($statement) or die "Can't prepare $statement: $dbh->errstr\n";
$sth->execute("$i") or die "Can't execute the query: $sth->errstr";
my @row = $sth->fetchrow_array;
my $folderName = $row[0];
my $accessLevel = $row[1];
my $userID = $row[2];
my $otherColumn = $row[3];
my $rows = $sth->rows();
$sth->finish;
#### Here is where I run into my question.
}
$dbh->disconnect;
Provided you are happy to depend on cookies just set a session cookie with the desired path and it will be delivered back to you when you hit that path. If you go to another subdomain you will get a different cookie/sessionID. If you want to set lots of session cookies, all globally accessible set the path as / (root) and they will all be available everywhere. You will then get all the sessid's for that user which can reference any data you care to set.
cheers
tachyon
perlmonks.org content © perlmonks.org and Stenyj, tachyon
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03