Ok, I have a Module I wrote with the help of Paul DuBois' "Perl and MySQL for the web". Which has taught me a lot.

I have modified a few parts of it to fit what I'm doing.

I've created an "admin" interface, whereby, the individual I've created it for, and myself can manage this site, including Registered users.

In the Admin interface there is a link that is for "managing users", if you click that, it will show their status, if they are verified(email), if they are admin(yes or no). If they are NOT an administrator, their is an option to add them, if they are, their is an option to remove them.

In both, I want it to Open EVERY session_id, Check the "session's username" as in the session, if exists.

For Adding "admin" powers, I want it to check if it is their session, and they are logged in, then if both of those are true, then it ADDS the variable the system checks to see if they are an admin user.

If it's to remove them, then it checks to find All THEIR sessions that are not deleted, and if they contain the variable that says they are admin users, then it deletes those variables. This way, if they are currently logged in, and I remove them, it's real time, not only after they log out and back in. and the other way around too. Where it will add them, real time, not only after they logout and back in.

So to do this, I added this to the code, in the appropriate place. Do you see a problem with this?
$cust_username = $dbh->selectrow_array(qq{SELECT username FROM + users WHERE id = "$in{id}"}); $sth1 = $dbh->prepare (qq{ SELECT * FROM session_db }); $sth1->execute(); while($row1 = $sth1->fetchrow_hashref()) { next if !$row1->{id}; $sess_ref1 = CWT::Site_DB->open_with_expiration(undef, $ro +w1->{id}); if($sess_ref1->attr("username") eq "$cust_username") { if ($sess_ref1->attr("logged_in") == 1) { $sess_ref1->attr("is_admin",1); } else { next; } } else { next; } } $sth1->finish();
I did it this way in the Remove them code:
$cust_username = $dbh->selectrow_array(qq{SELECT username FROM + users WHERE id = "$in{id}"}); $sth1 = $dbh->prepare (qq{ SELECT * FROM session_db }); $sth1->execute(); while($row1 = $sth1->fetchrow_hashref()) { next if !$row1->{id}; $sess_ref1 = CWT::Site_DB->open_with_expiration(undef, $ro +w1->{id}); if($sess_ref1->attr("username") eq "$cust_username") { if ($sess_ref1->attr("is_admin") == 1) { $sess_ref1->clear_attr("is_admin"); # Delete that +variable from sess. } else { next; } } else { next; } } $sth1->finish();


It seems like that would work. I use $sess_ref for the regular sessions, so I added 1 behind it to open each session.
This is not working. When I load the page, either adding or removing the admin "powers", it times out, then the dang site won't load for me for at least an hour. If I don't do that, then it just adds them or removes them depending on the action, but it don't work until they Next login.

Do you see a reason why this would not work?

Do you need to see more? If so, what part, module or the actual code surrounding the above extracts?

Thanks,
Richard

In reply to Sessions, Perl and MySQL by powerhouse

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.