在php会话中使用新行检测多个标题

时间:2015-01-12 06:13:24

标签: php session

无论我放在哪里 -

session_start();

它给了我错误

Header may not contain more than a 
single header, 
new line detected in /home/studiom/public_html/metriconline/tumblr/connect.php 
on line next to session_start();

我的代码是:

<?php
if(!ini_get('date.timezone'))
{
date_default_timezone_set('Asia/Kolkata');
}
require_once('tumblroauth/tumblroauth.php');
if(!session_id()){session_start();}
$consumer_key="myconsumerkey";$consumer_secret="secretkey";
$callback_url = "http://jrtrjujut.com/folder/tumblr/callback.php";
$tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret);
$request_token = $tum_oauth->getRequestToken($callback_url);
$_SESSION['request_token'] = $token = $request_token['oauth_token'];
$_SESSION['request_token_secret'] = $request_token['oauth_token_secret'];
switch ($tum_oauth->http_code)
{
case 200:
$url = $tum_oauth->getAuthorizeURL($token);
header('Location: ' . $url);
break;
default:
echo 'Could not connect to Tumblr. Refresh the page or try again later.';
}
exit();
?>

警告:标题可能不包含多个标题,第7行/home/studiom/public_html/metriconline/tumblr/connect.php中检测到新行

警告:session_start():无法发送会话缓存限制器 - 已在/ home / studiom / public_html / metriconline / tumblr中发送的标头(输出从/home/studiom/public_html/metriconline/tumblr/connect.php:7开始)第7行的/connect.php

警告:无法修改标题信息 - 已在/home/studiom/public_html/metriconline/tumblr/connect.php中发送的标题(在/home/studiom/public_html/metriconline/tumblr/connect.php:7中开始输出)第17行

1 个答案:

答案 0 :(得分:0)

在页面顶部使用session_start() 可能你已经开始了所以检查这个

<?php if(!session_id()){session_start();}

有关此错误的更多信息How to fix "Headers already sent" error in PHP