Jump to content

Problem with $_SESSION


Recommended Posts

I want to show de Logout button when $_SESSION['SESS_CATEGORY'] is 3 but i get a error: Parse error: syntax error, unexpected '<' in /home/ibn/public_html/escola/home.php on line 17

 

<?php

if(trim($_SESSION['SESS_CATEGORY']) == '3') {

 

echo <a href="actions/logout.php">Logout</a>;

 

exit();

 

}

 

?>

Link to comment
https://forums.phpfreaks.com/topic/244791-problem-with-_session/
Share on other sites

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>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.