Jump to content

Problem with $_SESSION


Recommended Posts

Worked. Now i`m having another problem when logouting...

 

Warning: Cannot modify header information - headers already sent by (output started at /home/ibn/public_html/escola/actions/logout.php:18) in /home/ibn/public_html/escola/actions/logout.php on line 19

 

<?php

//Start session

session_start();



//Unset the variables stored in session

unset($_SESSION['SESS_MEMBER_ID']);

unset($_SESSION['SESS_FIRST_NAME']);

unset($_SESSION['SESS_CATEGORY']);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Sair</title>

<link href="../loginmodule.css" rel="stylesheet" type="text/css" />

</head>

<body>

<?php

header("location: ../index.php");

?>

</body>

</html>

Link to comment
Share on other sites

Hi, adhbvklwqdbviabjiawdnbij < lol

 

"Warning: Cannot modify header information - headers already sent"

 

This is because session_start() and header("location: ../index.php"); are both sending header information.

Now, header information can only be send once, and must be sent BEFORE anything else is executed or sent to the browser..

 

Hence why your header() function is causing this error..

 

I personally use <meta http-equiv="refresh" content="0;URL=YOURURLHERE"/> as an alternative.

But be careful, this might not be XHTML valid, but we will work.

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.