Reference code below...
@ my question area noted in the code... A user will likely have access to
multiple sites under each several subdomains/databases.
I would like to create a session for each subdomain, containing an accessLevel
stored in the paramater of the folderName
ie. $session->param($folderName, $accessLevel);
The session would need to be retrievable by a cgi-bin for the subdomain.
So if the URL is:
http://www.$dbName.mysite.com/$folderName
then the cookie would need to be retrievable by scripts in:
http://www.$dbName.mysite.com/cgi-bin
I was figuring something like a bunch of if statements to determine which subdomain again
then adding the param to the appropriate session, based on which subdomain it's for.
Is there a way to create multiple sessions for each user, having multiple sessions being
created & modified at the same time?
If so, I'd probably end up just building the sessions in the code, then creating cookies,
each cookie referencing a session ID, once all the sessions have been fully created.
I have to figure out how to allow each cookie AND session to be accessible by the scripts.
# 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/subdo
+main
# 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 subdo
+main.
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, otherColu
+mn
FROM $dbName.areas
WHERE areaID = ?";
my $sth = $dbh->prepare($statement) or die "Can't prepare $stateme
+nt: $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;
Any help/feedback would be greatly appreciated!
Steny
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.