gilestodd Posted May 21, 2012 Share Posted May 21, 2012 I am having trouble resolving an error. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/s519970/public_html/header.php:27) in /home/s519970/public_html/admin/login.php on line 2 What I can gather is I can't use "header (Location: 'admin.php')" after i've used session_start(). I have tried to replace the header (Location: 'admin.php') with this: echo "<script>document.location.href='admin.php'</script>"; echo "<script>'Content-type: application/octet-stream'</script>"; I've been trying to read up on solutions but haven't been able to get it sorted. If anyone can offer some advice that would be greatly appreciated as im new to php. <?php session_start(); if(isset($_SESSION['user'])) echo "<script>document.location.href='admin.php'</script>"; echo "<script>'Content-type: application/octet-stream'</script>"; ?> <div id="loginform"> <form action="dologin.php" method="post"> <table> <tr> <td><span>Username:</span></td> <td><input type="text" name="username" /></td> </tr> <tr> <td><span>Password:</span></td> <td><input type="password" name="password" /></td> </tr> <tr> <td colspan="2" align="right"><input type="submit" name="login" value="Login" /></td> </tr> </table> </form> </div> I have tried using require_once('yourpage.php'); before my <head></head> tags in the header document where I've specified the html information but this doesn't seem to work. I've been advised to use ob_start("ob_gzhandler"); but I am not sure how to implement this. Any advice is greatly appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/262874-warning-session_start-functionsession-start-cannot-send-session-cache/ Share on other sites More sharing options...
TOA Posted May 21, 2012 Share Posted May 21, 2012 What I can gather is I can't use "header (Location: 'admin.php')" after i've used session_start(). I have tried to replace the header No, you can. You can't use it after outputting something though. The error tells you you're output started in 'header.php' at line 27. See this sticky. Quote Link to comment https://forums.phpfreaks.com/topic/262874-warning-session_start-functionsession-start-cannot-send-session-cache/#findComment-1347304 Share on other sites More sharing options...
gilestodd Posted May 22, 2012 Author Share Posted May 22, 2012 Thank you, should have read that sticky first! Quote Link to comment https://forums.phpfreaks.com/topic/262874-warning-session_start-functionsession-start-cannot-send-session-cache/#findComment-1347572 Share on other sites More sharing options...
TOA Posted May 22, 2012 Share Posted May 22, 2012 Did it help? Quote Link to comment https://forums.phpfreaks.com/topic/262874-warning-session_start-functionsession-start-cannot-send-session-cache/#findComment-1347574 Share on other sites More sharing options...
gilestodd Posted May 29, 2012 Author Share Posted May 29, 2012 Yes it did indeed! Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/262874-warning-session_start-functionsession-start-cannot-send-session-cache/#findComment-1349467 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.