• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

Help on Single Sign On

I configured and set up the SSO (single sign on) to access my Web server.

S.O: Linux
Web Server: Apache

Below the steps:

- Configured the Policy Domain and create a new Authentication Scheme on Oracle Access Manager
- Modify the http.conf file and add the rows:
ProxyPass /dbcenter/entry.php      !
ProxyPass /dbcenter/login.php      !

- Create the file: entry.php  - login.php - myweb.php  (see attached files)

Now when I try to connect at my portal web: I get this warning:

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/dbcenter/login.php:3) in /var/www/html/dbcenter/login.php on line 24

and then successfully entered

Have any idea how to avoid this warning?
2 Solutions
This is nothing specific to SSO - this is a generic PHP / HTML problem. This happens because all  web servers send back data in a very specific order:

1. HTTP Headers
2. Content

HTML belongs in the Content area, while any calls such as header() or setcookie() change information in the HTTP Headers area.

Once you send any Content, the web server assumes you are finished sending HTTP Headers, so it won't allow you to send any more HTTP Headers at that point.

There are several ways to fix this, but the easiest is probably just to add this line above your login.php script:

<?php ob_start(); ?>

This is called starting an output buffer (ob = output buffer). Basically, whenever it comes across any Content like HTML, it will not automatically output the HTML to the screen, but instead will put it into a hidden variable called an output buffer. Since the web server hasn't sent any Content back (because it's in the output buffer), it is still in the mode of expecting and accepting HTTP Header changes, so the setcookie() will work.

Now, there are ways to access and manipulate the contents of the output buffer, but you don't need to do anything more, since the output buffer will automatically dump whatever it has at the end if you don't do anything else.

Usually the proper way to get around this is to simply write code so that you do all your PHP processing first, and then display any HTML once you're done with PHP, but the ob_start() is a quick fix.
Scott MadeiraCommented:
You need to send header information prior to outputting anything to the browser window.  Even stray white space at the end of a .php file can cause this error.  you are having a problem here because you send stuff to the browser prior to the setcookie command.  If you rearrange your login.oho file as follows, it should work for you.

	$txtUserID = $_POST["IDUser"];
    $token = $_POST["mytoken"];

	$cookieValue = $token; 
    $cookieExpiration = 0; 
    $cookiePath = "/"; 
    $cookieDomain = "gruppocattolica.it"; 

	$input_arr = 
			"txtUserID" => $txtUserID

<script language="javascript">
    function goSubmit() {
<body onload="goSubmit();">
<form action="http://myportal.it/dbcenter/entry.php" method='POST' name='formric'>
		foreach($input_arr as $key => $value)
		  echo "\t" . '<input type="hidden" name="' . $key . '" value="' . $value .'">' . "\n";

Open in new window


Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now