-1

I'm going out of my mind right now. I can't figure out what the heck is causing these stack dump warnings. I have PHP errors not being shown so not sure why it's even showing the warning but I just need to figure out what is happening here. Any help would be greatly appreciated.

============================================================= [Warning]: Undefined array key "userid"

Stack Dump:

errorHandler(integer(2), string("Undefined array key "userid""), string("/home/domain/public_html/prgprofile.php"), integer(40)) [/home/domain/public_html/prgprofile.php:40]

include_once(string("/home/domain/public_html/prgprofile.php")) [/home/domain/public_html/skins/blusk/index.php:58]

include(string("/home/domain/public_html/skins/blusk/index.php")) [/home/domain/public_html/lib/class.Skin.php:86]

Skin->ShowIndex(string("member")) [/home/domain/public_html/index.php:28]

==============================================================

A. What could be causing this? B. How can I stop these warnings from happening?

After user registers I get these warning.

  • The first thing to do is look at line 40 of `prgprofile.php` and ask yourself why that array might not have key `userid`. – Jerry Apr 16 '23 at 02:27
  • This is my line 40: $Sess_UserId= $_SESSION['userid']; – Michael Allen Apr 16 '23 at 02:30
  • First, distinguish the differences between warnings and errors. Secondly, use code to `check the existence` of $_SESSION['userid'] **before** using it. – Ken Lee Apr 16 '23 at 02:40
  • give code for better understanding – vatsal mangukiya Apr 16 '23 at 04:01
  • Does this answer your question? ["Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP](https://stackoverflow.com/questions/4261133/notice-undefined-variable-notice-undefined-index-warning-undefined-arr) – Tangentially Perpendicular Apr 16 '23 at 18:38

1 Answers1

0

Your session is not set. To remove error , you can use this

$_SESSION['userid'] ?? 0; 

This will fix the warning but you will still have no userid in your session variable.

doraemon
  • 325
  • 1
  • 4
  • 16