Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Inglés Show captive portal logged in users

    Scheduled Pinned Locked Moved Captive Portal
    captiveportalproblempfsense
    4 Posts 2 Posters 753 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      cxcx_avjj
      last edited by

      Hi guys, I have a problem...
      I have a PfSense with a captive portal that provides services to users. The idea would be that when someone logs in, in the logout page "logout.php" shows the name of the user and the available time of the account. I tried to print the $user variable from index.php, but it doesn't work.

      In short, print the customer's name and the time available on the user's logoff page. Thank you

      GertjanG 1 Reply Last reply Reply Quote 0
      • GertjanG
        Gertjan @cxcx_avjj
        last edited by

        @cxcx_avjj said in Inglés Show captive portal logged in users:

        The idea would be that when someone logs in, in the logout page "logout.php" shows

        The idea is great, and has been mentioned many time.
        Yes, the logout page comes from pfSense, so all the information you need is present.

        But I'll give you some more information.
        I'm sorry upfront fo rwhat is about to come.

        Here it is : what is the action that most users do as soon as they start to use a browser (any browser) ?
        They switch off those nasty popup windows.
        And worse, most portable phones/pad device use special browser that even don't store cookies for later usage, or allow popups. They (the phone OS) launches this special system browser to permit the user to login. Then it stops. The user should now open his browser he chooses - an app like Edge, Firefox or Chrome, and now he can access the Internet. Or he launches the mail app.
        PC type devices might show message in the top or bottom that the site (the captive portal login server == pfSense) send a popup windows, and if the user accepts that message, he will see the logout popup page.
        Most even don't see that browser message. These are my conclusions, as I'm using the captive portal for more then a decade now.

        So, making your own logout popup windows might be useful. But very few will ever see it.

        No "help me" PM's please. Use the forum, the community will thank you.
        Edit : and where are the logs ??

        C 1 Reply Last reply Reply Quote 0
        • C
          cxcx_avjj @Gertjan
          last edited by

          @gertjan Dude, I got part of the plan...My logout window is not a browser popup.
          When you log in to the PfSense Captive Portal you are immediately redirected to the final url. From here you can manually close your session.
          This little problem does not happen in OPN Sense where by default it is configured to redirect you to logout.php
          The idea is to show in my logout the username and the time available...
          Note: sorry if there is an error in my English it is because I used a translator

          GertjanG 1 Reply Last reply Reply Quote 0
          • GertjanG
            Gertjan @cxcx_avjj
            last edited by

            @cxcx_avjj

            Hummm.

            After a success login, I simply redirect the user to the known :

            95300287-8e35-4a7f-823b-a26585729c92-image.png

            as that would make the user understand he is 'online'.

            But I could also redirect to a "home made", locally available web page, like the portal login page.
            This file should be uploaded with the Services>Captive Portal>CPZONE>File Manager
            Be aware : the prefix "captiveporal-" will get prefixed.

            Take a look at what this button shows you :

            c3c27d9a-d1d4-4fb1-9c2d-c7c7bc0515fc-image.png

            You will see the login page.
            And more important : the URL used, with the port number, as it is not port 80 (http) or 443 (https). Probably a 800x port.
            And the zone ID used with a parameter called 'zone'.

            So, this is posisbile :
            ec125b9e-23a2-4703-86f7-640e3760853a-image.png

            Where :
            https://portal.yourzone.tld = your captive portal URL - I'm a https access
            :8003/ The port of this 'cpzone1 ID access
            captiveportal-recap.html My home made file called 'recap.html'
            ?zone=cpzone1 My zone ID of this portal zone

            The "recap.html" html can have use PHP !
            And because you can use PHP, and the recap.html is called with the "?zone=cpzone" parameter, you can now access whatever you want !

            Take /usr/local/captiveportal/index.php as an example. You'll see how it extract the zone argument.
            If, for example, you use vouchers, you can test vouchers for time left : Status > Captive Portal > CPZONE > Test Vouchers
            Just take a look at /usr/local/www/status_captiveportal_test.php and you'll know how to extract the time from a given voucher.

            How do you know what voucher is used ?
            Well, your 'recap.html' can obtain the IP your device is using.
            With this IP, and the "connected users database" (see /etc/inc/captiveportal.inc - this file is a must-read-and-understand) you can get the user login code, which is the voucher code.
            With the voucher code you can obtain the time left.

            Want to know what the default popup logout window does - or how to log out a user?
            Again, go have a look at /etc/inc/captiveportal.inc

            So, yes, the sky is the limit.
            An yes, this goes beyond what you can find in the GUI.

            No "help me" PM's please. Use the forum, the community will thank you.
            Edit : and where are the logs ??

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.