Jump to content

$_session Error?


herghost

Recommended Posts

Hi All, I am having a bit of trouble with checking if a session is set.

 

the error I am getting is:

Notice: Undefined variable: _SESSION in C:\wamp\www\jolly\office\lpanel.php on line 5

 

on my home page, I have this:

<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
$('#leftpanel').load('lpanel.php').fadeIn("slow");
}, 10000); // refresh every 10000 milliseconds
</script>

 

which refreshes the contents of lpanel.php every 10 seconds.

 

The code of lpanel.pho is:

<?php

if(isset($_SESSION['delete']))
echo "<script language=javascript>alert('Customer Deleted')</script>";
unset($_SESSION['delete']);
?>

 

session_start is already initiated by header.php

 

Any ideas on how to fix the error?

I have echo'd out the $_session['delete']; and the value is correct.

 

Thanks

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/194247-_session-error/
Share on other sites

You would only get that if your code already included lpanel.php and now you are trying to make a http request to it.

 

You would need to provide a lot more detail about what your code is doing, but best guess is that you need to create a separate file with the code you need in it with a session_start() statement.

Link to comment
https://forums.phpfreaks.com/topic/194247-_session-error/#findComment-1021928
Share on other sites

I now kinda have it working, I had an error on another page. It works fine as is if I only have the one if statement, however if I have

 

<?php
if(isset($_SESSION['delete']))
{
echo "<script language=javascript>alert('Customer Deleted')</script>";
$_SESSION['delete'] = null;
}
elseif(isset($_SESSION['display']))
{
echo "add customer";
$_SESSION['display'] = null;
}
?>

 

Then I get this error:

 

Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0

 

?

 

 

Link to comment
https://forums.phpfreaks.com/topic/194247-_session-error/#findComment-1021938
Share on other sites

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.