For Raspberry Pi OS (rather than the older raspbian), first install the Default Applications for LXsession package, which used to be prebundled but now requires you to install it yourself:
sudo apt -y install lxsession-default-apps
Then, go to the the menu's "preferences", run "Main Menu Editor", select the preferences category on the left, and then enable "Default Applications for LXsession" so it shows up in the menu from now on:

Then run that, and go to "Autostart":

And then just add new entries for whatever you need to have run on user login and restart the pi for the changes to kick in.
However: this can only run applications "as you", so if you need to run commands that require sudo, you have two options:
- write a
system.d service. Lots of great tutorials on this but it's a rabbit hole: good luck.
- "preclear" your specific script in
/etc/sudoers with the more than obvious security implications. And if you mess up, you may need a (virtual machine'd) linux to mount your SD card and edit the sudoers file on a separate machine.
(while staying away from rc.local: that runs at part of the boot process, which means it's completely useless if you need something to happen when a specific user logs in).
And of course, remember that not everything needs sudo (for example, mounting a samba share as regular user just requires an fstab entry that includes ,user instead of forcing the issue using sudo, etc).