*question near end, but explanation needed to understand what I'm trying to do*
I'm using CGI::Sessions with my site.
My site has many areas & sub areas. Each of which have different access requirements, etc.
When a user logs in, I would like to send a hash to the session that will then contain another hash.
The first hash's keys will be specific to each subdomain of my site. The hashes reference to by the keys will then hold the access permissions for that subdirectory (each key in the subhash will be for a directory and contain info for the user's access).
ie.
sports.sitename.com
- football
- basketball
- soccer
animals.sitename.com
- dogs
- cats
- birds
games.sitename.com
- tetrinet
- marioworld
- counter-strike
others.sitename.com
- random
- stuff
The session will contain:
- userID = user id
- alias = name of user
- access = 0 or 1... (1 = logged in)
then also a :
- access = { %sports => { football => 1, soccer => 1 }, %games => { counter-strike => 1 } };
NOTE: the only data that will be stored is when a user DOES have access to a subdomain and DOES have access to a folder.
from the value of 'access' above, you can see the user only has access to a folder under the sports & games subdomains, so only those two are stored in the session.
****************************************************
My question is:
if I have an array as follows:
@sports = (football, soccer);
@games = (counter-strike);
how can I create the hash that will be stored in 'access'?
As always, I appreciate your patience with my steep learning curve ;-P
Any help/feedback would be greatly appreciated!
Stenyj
P.S. An example of what my deluded mind is kind of trying to do:
my @sports = ('soccer', 'football');
my @games = ('tetrinet', 'counter-strike');
my %access;
foreach my $s (@sports) {
$access{sports} .= {$s => 1};
}
foreach my $g (@games) {
$access{games} .= {$g => 1};
}
my $empty;
my $session = new CGI::Session(undef, $empty, {Directory=>"c:/apache/c
+gi-bin/tmp"});
$session->param("access", %access);
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.