herghost Posted March 5, 2010 Share Posted March 5, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/194247-_session-error/ Share on other sites More sharing options...
dgoosens Posted March 5, 2010 Share Posted March 5, 2010 try like this: <?php if(isset($_SESSION['delete'])) echo "<script language=javascript>alert('Customer Deleted')</script>"; $_SESSION['delete'] = null; ?> Quote Link to comment https://forums.phpfreaks.com/topic/194247-_session-error/#findComment-1021921 Share on other sites More sharing options...
PFMaBiSmAd Posted March 5, 2010 Share Posted March 5, 2010 Your code is making a HTTP request for lpanel.php. That has nothing to do with any other content on the page and you must put a session_start() statement in lpanel.php if you want to use session variables in it. Quote Link to comment https://forums.phpfreaks.com/topic/194247-_session-error/#findComment-1021925 Share on other sites More sharing options...
herghost Posted March 5, 2010 Author Share Posted March 5, 2010 No error, but does not activate java alert, i tried changing just to echo a text message and nothing either PFMaBiSmAd - then i get a session already started message Quote Link to comment https://forums.phpfreaks.com/topic/194247-_session-error/#findComment-1021926 Share on other sites More sharing options...
PFMaBiSmAd Posted March 5, 2010 Share Posted March 5, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/194247-_session-error/#findComment-1021928 Share on other sites More sharing options...
herghost Posted March 5, 2010 Author Share Posted March 5, 2010 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/194247-_session-error/#findComment-1021938 Share on other sites More sharing options...
PFMaBiSmAd Posted March 5, 2010 Share Posted March 5, 2010 Like the error states, turn off one or both of the settings that are mentioned in the message. Quote Link to comment https://forums.phpfreaks.com/topic/194247-_session-error/#findComment-1021944 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.