Jump to content

Session Errors


havox

Recommended Posts

I apologize to keep posting this in different topics, but since I can't edit my last topic to fit this one; I must.

 

<?php
error_reporting(-1);
ini_set('display_errors', 1);

function check() {

$admin="test";
$pass="test";

if (isset($_POST["user"]) && $_POST["user"] == $admin && isset($_POST["pwd"]) && $_POST["pwd"] == $pass) {
		sesshin(); }
}
function sesshin() {

session_start(); 
$_SESSION['user'] = "test";

if ($_SESSION['user'] = "test") {
	header('Location: output.php'); }
else {
	header('Location: index.html'); }
}
?>

 

I get the following errors when I try to login.

 


Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /srv/www/deadnode.com/public_html/function.php:25) in /srv/www/deadnode.com/public_html/function.php on line 15

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /srv/www/deadnode.com/public_html/function.php:25) in /srv/www/deadnode.com/public_html/function.php on line 15

Warning: Cannot modify header information - headers already sent by (output started at /srv/www/deadnode.com/public_html/function.php:25) in /srv/www/deadnode.com/public_html/function.php on line 1

 

I've just confused myself into doing this. Maybe I can do all of this in one function? Check(), should look to see if the form information is correct. If so, then it should start the session and proceed to the output.php page. The other thing I'm trying to figure out is how to block public view of output.php if you havent logged in.

Link to comment
Share on other sites

Ok the issue is fixed it goes through all the steps. I'm trying to make a redirect back to index.html if someone try just go ahead and go to one of my pages.

 

I added this to my function.php

 

function blah() {

if ($_SESSION['user'] != "test") {
	redirect('Location: index.html'); }
}

 

I get the following error

 

Parse error: syntax error, unexpected $end in /srv/www/deadnode.com/public_html/function.php on line 30

 

I have no idea if redirect is even real it just highlighted like header did so I figured I would try. Would http_redirect work?

Link to comment
Share on other sites

I'm getting this error now

 

Notice: Undefined variable: _SESSION in /srv/www/deadnode.com/public_html/function.php on line 29

Warning: Cannot modify header information - headers already sent by (output started at /srv/www/deadnode.com/public_html/function.php:37) in /srv/www/deadnode.com/public_html/function.php on line 30

 

I'm assuming it cannot see that session has been started, because its started within the function?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.