dポイントプレゼントキャンペーン実施中!

Auth認証をするとログインには成功するものの下記のようなエラーが出てしまいます。解決策はございませんでしょうか。ご教授願います。

Warning: session_regenerate_id() [function.session-regenerate-id]: Cannot regenerate session id - headers already sent in /usr/local/php5/php/Auth.php on line 810

Warning: Cannot modify header information - headers already sent by (output started at /home/sites/heteml/*****/*/*/*/*****/****/*****/*****/index.php:8) in /usr/local/php5/php/Auth.php on line 838


ちなみにphpファイルは下記を実行しています。
<?php
require_once("Auth/Auth.php");
function loginFunction($username, $status, $auth){
if ($status == AUTH_WRONG_LOGIN){
print("ユーザー名又はパスワードが間違っています<br>");
}
print("<form method=\"post\" action=\"index.php\">");
print("<table>");
print("<tr>");
print("<td>ユーザー名</td>");
print("<td><input type=\"text\" name=\"username\"></td>");
print("</tr>");
print("<tr>");
print("<td>パスワード</td>");
print("<td><input type=\"password\" name=\"password\"></td>");
print("</tr>");
print("<tr>");
print("<td colspan=\"2\"><input type=\"submit\"></td>");
print("</tr>");
print("</table>");
print("</form>");
}
$params = array(
"dsn" => "mysqli://authuser:authpass@localhost/authdb",
"table" => "authtable",
"usernamecol" => "username",
"passwordcol" => "password"
);
$authobj = new Auth("DB", $params, "loginFunction");
$authobj->start();
if ($authobj->getAuth()){
echo 'ログイン済み';
}else{
echo '未ログイン';
}
?>

補足ですが、サーバーはヘテムルを使用しています。

A 回答 (1件)

session_regenerate_id()が行われる前に、


echo や print等で、何らかの出力がされていたりすると、
このようなエラーが出る気がします。
(同様に、session_regenerate_id()が行われる前に、
「改行」や「スペース」が有っても、アウトですので、
そのあたりも、注意深く調べてみて下さい。
どちらも気付きにくいので、しばしば苦労します。)

session_start();などは、
ページ先頭で行う必要があります。

参考になると思われるページ
http://oshiete1.goo.ne.jp/qa5243992.html
(似たような回答を先日しましたので…参考までに)
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!