locked
session if statement RRS feed

  • Question

  • User643189141 posted

    Hi,

    I used Session["ID"] = 8

    How to use if statement if(Session["ID"]==8) { //my code }

    This code not works.

    Regards,
    Dejan

    Friday, July 20, 2012 4:44 PM

Answers

  • User1264447444 posted

    use 

    if(((int)Session["ID"])==8)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 20, 2012 4:47 PM
  • User-231977777 posted

    try

    if((int)Session["ID"] == 8){   yourcode  }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 20, 2012 4:48 PM

All replies

  • User1264447444 posted

    use 

    if(((int)Session["ID"])==8)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 20, 2012 4:47 PM
  • User-231977777 posted

    try

    if((int)Session["ID"] == 8){   yourcode  }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 20, 2012 4:48 PM
  • User-1944332692 posted

    Hi,

    Check this code.

    if (Session["ID"] != null) {if (Convert.ToInt16(Session["ID"]) == 8){ //DO your code    } }

     Regards,

    Anwar Sadat

    Thursday, August 2, 2012 3:01 AM