PHP - hide url (GET) parameters

PHP - hide url (GET) parameters

  1. Blog
  2. 15 November 2026
  3. 5 min read

Stefan Bogdanescu

Founder & Senior Architect

The Illusion of Security in URL Parameters

You are facing a common architectural constraint: you need to pass sensitive data like usernames and passwords to a third-party service via a direct link, but you want those parameters to remain invisible to the end-user. The short answer is no, not if your goal is "hiding" them from the user's browser or network traffic.

When a browser requests http://search.mywebsite.com/login.aspx?checktype=uid&user=adam&password=pass1234, the URL string is rendered as part of the address bar immediately upon loading. Even if you wrap this in JavaScript to obfuscate the string before appending it to the anchor tag, modern browsers and browser extensions will decode the URL for display purposes once the request completes. Furthermore, every intermediate proxy, firewall, or logging server along the network path can see the plaintext parameters in the HTTP request line.

If "hiding" implies preventing the user from reading the text in their address bar, you must fundamentally change how the data is transmitted. Since you are constrained against using a standard HTML form POST and cannot control the receiving endpoint to accept POST requests, your only viable technical path is client-side obfuscation combined with a redirect mechanism.

Client-Side Obfuscation as a Mitigation Strategy

Since the receiving server expects a GET request with parameters in the query string, you can modify the client-side behavior to strip or scramble these values before the URL is finalized. This does not encrypt the data on the wire; it simply prevents the plaintext password from ever being written into the browser's history or address bar.

The standard pattern for this involves a JavaScript event listener attached to the link click. When the user clicks, you intercept the default navigation behavior, construct a new URL where sensitive parameters are set to an empty string or a placeholder, and then programmatically trigger the navigation.

Here is how you might implement this in your PHP environment by injecting a script that handles the click event:

<script>
(function() {
    // Select all links targeting the third-party login
    var link = document.querySelector('a[href*="login.aspx"]');
    
    if (link) {
        link.addEventListener('click', function(event) {
            // Prevent default navigation immediately
            event.preventDefault();

            // Extract original URL components
            var urlObj = new URL(this.href);

            // Strategy: Remove sensitive params from the query string
            // This ensures the address bar never shows 'user=adam&password=...'
            urlObj.searchParams.delete('user');
            urlObj.searchParams.delete('password');

            // Note: You must ensure the 3rd party site handles missing params gracefully
            // or that you are passing a session token instead of raw credentials.
            
            // Redirect to the cleaned URL
            window.location.href = urlObj.toString();
        });
    }
})();
</script>

The Critical Security Trade-Off

It is imperative to address the security implications of this approach. By stripping user and password from the URL before redirection, you are relying entirely on the third-party website's ability to handle the request without those fields, or by validating them against a session token stored in a cookie.

If the third-party site (login.aspx) strictly requires those GET parameters to function, removing them will break the login flow for your users. If they do not require them, then sending plaintext passwords via URL parameters was never a secure practice to begin with. Modern security standards dictate that authentication credentials should never be passed via GET requests, regardless of obfuscation, because:

  1. Browser History: Users often copy URLs from the address bar or view history. If the parameter exists in the final URL, it is visible.
  2. Server Logs: Every web server, including your own and every proxy in between, logs the full request line. Your own PHP script will log the full URL with the password before redirecting, creating an audit trail of sensitive data on your infrastructure.
  3. Referrer Headers: When the user lands on the third-party site, they may send a Referer header back to your domain if they navigate away or submit forms elsewhere, potentially leaking the original (obfuscated) URL structure.

The Real Solution: Session Tokens

The industry-standard solution for this specific scenario is not to hide the parameters, but to eliminate them. You should implement a server-side session token.

Your PHP backend should generate a unique, random string (e.g., a UUID or a secure hash) and store a mapping of that token to the user credentials in your own database. When the user clicks the link:

  1. The link contains only the token in the query string (e.g., ?token=abc123).
  2. Your PHP script intercepts the request, validates the token, and looks up the actual user/password.
  3. Instead of forwarding the raw credentials to the third party, you either:
    • Forward the token to a specific endpoint on the third-party site that accepts tokens (if they support OAuth or similar).
    • Or, if the third party must have the raw credentials, you are forced to accept that sending them via GET is inherently insecure.

If the third-party site absolutely requires user=adam&password=pass1234 and offers no alternative endpoint, then you cannot hide the parameters without breaking functionality, nor can you safely use a direct link. The only secure way to pass credentials in this scenario is to force the user into a POST submission via a hidden form that redirects after submission, or to implement a two-step login where the initial link triggers a redirect to a page hosted by your domain where the actual login happens server-side before the final redirect to the third party.

Attempting to obfuscate passwords in URL parameters provides a false sense of security. It masks the data from the user's immediate view but leaves it exposed in server logs, browser history, and network traffic analysis tools. The architecture must change to avoid transmitting sensitive credentials via GET requests entirely.

Our network