Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^8: global var

by tultalk (Monk)
on Apr 07, 2017 at 22:24 UTC ( [id://1187436]=note: print w/replies, xml ) Need Help??


in reply to Re^7: global var
in thread global var

Answer his and one above.

Manageusers is the "main" unit in the sense that everything get funneled back to that unit for accessing database tables and all the login /logout functions. I consider it the "main" unit to which manage_users.cgi interfaces between thr web pages and the guts of the program.

The loggedonuser the ID of the user far accessing various other pieces of data such a database records "owned" by the user.

The change from LoggedOn_user_id to GetLoggedOn... and back again was a result of trying an exported function result to pass the id vs a scalar variable. Neither worked.

Other functions/.scalars are exported just fine. Not this one!!!

Replies are listed 'Best First'.
Re^9: global var
by Anonymous Monk on Apr 07, 2017 at 23:23 UTC

    ...Other functions/.scalars are exported just fine. Not this one!!!

    Then it shouldn't be too hard to duplicate that error in 20 lines, and post it here, right?

      A previous comment posted code as you suggest. It worked fine when I tested it. I have something screwed up somehow and I can't see it.

      Posting question here was hoping for some insight as to why something like this may be occurring.

      These are two declarations (same location in manageusers just before first function definition.

      our $adminaccess = 0; our $LoggedOn_user_id = 0;

      As I said in an earlier response, I can grab $adminaccess in javascript in html page.

      <script type="text/javascript"> var adminflag = $manageusers::adminaccess; </script>

        Declaration: our $LoggedOn_user_id = 0;

        This is line from error log (warns):

        $LoggedOn_user_id = $username1; warn("Already logged on LoggedOn_user_id : '$LoggedOn_user_id'");

        Already logged on LoggedOn_user_id : '428' at /home/jalamior/www/httpsdocs/cgi-bin/lib/perl/manageusers.pm line 287.

        And in the other unit

        use manageusers qw(LoggedOn_user_id);

        Tried different variations of qw(LogggedOn.. and qw($LoggedOn.. Neither worked.

        $userid_1 = $LoggedOn_user_id; warn("userid : '$userid_1' ");

        What I get back is

        <h1>Software error:</h1> <pre>&quot;LoggedOn_user_id&quot; is not exported by the manageusers m +odule Can't continue after import errors at update_tables-development.cgi li +ne 30 BEGIN failed--compilation aborted at update_tables-development.cgi lin +e 30. </pre>

        Mangeusers export

        BEGIN { require Exporter; use vars qw($VERSION @ISA @EXPORT_OK); use DBI; # use vars qw(@ISA @EXPORT_OK); # $ENV{DBI_TRACE}=1; # $ENV{PERL_DBI_DEBUG}=1; @ISA = qw(Exporter); # exported functions our @EXPORT_OK = qw( &OpenConnection &OpenSession &ProcessLoginRequest &ProcessLostDataRequest &LoginUser $LoggedOn_user_id &decodeEncryptedPassName &UpdateUserData &GetUserLostData &LogoutUser &GetUserSessionCookie &CheckForAuthorizedUser &Expires $attempts $adminaccess &Now &CheckValidLoginChar &CheckValidEmailChar &print_md5_javascript); $VERSION = '0.0.1'; }

        Before I was led to use EXPORT_OK. I was at least getting zero in $userid_1

        $userid_1 = $LoggedOn_user_id; warn("userid : '$userid_1' ");

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1187436]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2025-11-12 04:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (68 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.