Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is unsetting $_SESSION variable a bad idea before setting session var?

Tags:

jquery

php

In a page I'm designing, I'm storing data via $_session but since I'm calling the pages dynamically with jquery I wanted to add some security and unset($_SESSION['var']) before i set them just in case anything would happen. My question is if unsetting session a bad idea before it is set, or is it completely valid?

like image 207
Logan Avatar asked May 25 '26 07:05

Logan


1 Answers

It's unnecessary and will have no effect.

If you are calling sensitive data through Ajax calls, you need to properly secure it against attacks, just as you would secure a normal page - for example by having a session-based login, and checking whether the current user is logged in!

like image 63
Pekka Avatar answered May 26 '26 20:05

Pekka