Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Lolu chungechunge lwabekwa kunqolobane. Uyacelwa ubuze umbuzo omusha uma udinga usizo.

Some php code works in all browsers except firefox, why?

more options

This PHP code works in all browsers except FireFox.

$_SESSION['user_level'] = (int) $_SESSION['user_level']; // Changes the 1 or 2 user level to an integer
$url = ($_SESSION['user_level'] === 1) ? 'admin-page.php' : 'members-page.php'; // Ternary operation to set the URL
header('Location: ' . $url); // Sends the user to one of the pages. The $url is a relative path

FF will send a user to members-page.php, but the user with a level of 1 only works in all other browsers including IE8.

This PHP code works in all browsers except FireFox. <pre><nowiki>$_SESSION['user_level'] = (int) $_SESSION['user_level']; // Changes the 1 or 2 user level to an integer $url = ($_SESSION['user_level'] === 1) ? 'admin-page.php' : 'members-page.php'; // Ternary operation to set the URL header('Location: ' . $url); // Sends the user to one of the pages. The $url is a relative path</nowiki></pre> FF will send a user to members-page.php, but the user with a level of 1 only works in all other browsers including IE8.

Okulungisiwe ngu cor-el

All Replies (2)

more options

This page seems to require nothing of the browser but a session cookie to send the correct redirect. Is it possible the cookie is not being received, so the test always defaults to false (because the request does not connect with the user's actual session)? You could create a test page to see whether your server is receiving the PHP session cookie from Firefox.

To see whether Firefox is sending the cookie, you can use the web console. Just before loading that page, press Ctrl+Shift+k to open the web console, click the CSS button to hide style warnings temporarily (those clutter up the list) and click Clear. Then hit your page. Various requests should appear in the console. Scroll back to the top of the list and click the URL to display the request and response headers and cookies. Does that give any insight?

Actually, I'm not sure whether the console will show the original request or the redirect request. You might need to use an external proxy (such as Fiddler) to see all the requests.

more options

The forum software detected your Firefox as version 14. Is that correct?

Version 14 is not secure; Mozilla discloses security flaws after each new release. Is something holding you back from upgrading to Firefox 24? Please let us know so we can suggest solutions or workarounds.

If Help > About Firefox shows Firefox 24.0, you may need to clear the preference that is misreporting your version number. See: How to reset the default user agent on Firefox.