Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

PHP Session VS. Session isset

php session

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1 Serialcek

Serialcek

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 151 posts

Posted 31 January 2014 - 12:11 AM

So I have this two option to use:

$_SESSION["select_hero"] = mysql_real_escape_string($_POST["select_hero"]);
$_SESSION["select_hero"] = isset($_POST["select_hero"]) ? 
                mysql_real_escape_string($_POST["select_hero"]) : "";

In this case let's say that a user can choose between one heroes using a radio button. I do not 100% understand what is the point/difference between this two Sessions.

Thx for any help with understanding..



#2 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts

Posted 31 January 2014 - 05:19 AM

The later checks first if the variable is POSTed before assigning it, this is actually a good thing, as newer PHP would generate warnings on the first approach if the variable isn't set from the form. 


I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#3 Serialcek

Serialcek

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 151 posts

Posted 31 January 2014 - 05:32 AM

Great, thx!






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download