PHP Session Handling vs. ASP Session Handling

Just because you created a session variable in PHP, using this statement:


 // store session variables to designate that the user is successfully logged in! 
 $_SESSION["login"] = TRUE;
 $_SESSION["username"] = $varUserName;    

doesn’t mean you can automatically access the $_SESSION(“login”) variable from another program!

In ASP, once the session variable is created, you’re good to go and can access it immediately from any other program.

value = Session("username")   ' this works fine in ASP, no need for a session_start()

In PHP, you must also use the command


before you can use the $_SESSION variable you created…

So session_start() is not just needed when you want to create a new session variable, it’s also needed when you want to access your session variables.

I guess I should put this command in my include/common.php file, so it’s always available to me and not have to worry about whether it was set or not.  Just session_start it automatically for all users!

This entry was posted in Uncategorized. Bookmark the permalink.