Solved

Help on Single Sign On

Posted on 2013-01-08
2
351 Views
Last Modified: 2013-01-09
Hi,
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: http://10.11.12.33/myweb.php 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?
entry.php
login.php
myweb.php
0
Comment
Question by:ralph_rea
2 Comments
 
LVL 35

Assisted Solution

by:gr8gonzo
gr8gonzo earned 200 total points
ID: 38756091
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.
0
 
LVL 14

Accepted Solution

by:
Scott Madeira earned 300 total points
ID: 38756302
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.

<?php
	$txtUserID = $_POST["IDUser"];
    $token = $_POST["mytoken"];

	$cookieValue = $token; 
    $cookieExpiration = 0; 
    $cookiePath = "/"; 
    $cookieDomain = "gruppocattolica.it"; 
    setcookie("mytoken",$cookieValue,$cookieExpiration,$cookiePath,$cookieDomain);

	$input_arr = 
		array(
			"txtUserID" => $txtUserID
			);    
?>

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

Open in new window

0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question