Jump to content

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

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.