How To Create a Session Variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sanamashokreddy
    New Member
    • Apr 2008
    • 8

    How To Create a Session Variable

    Exaplain me with an example


    that will be a great help for me

    Thanks in Advance
  • Mr Gray
    New Member
    • Apr 2008
    • 47

    #2
    Hello,

    You can create a session variable like so:

    Code:
    Session["Name"] = value;
    Thanks.

    Comment

    • sanamashokreddy
      New Member
      • Apr 2008
      • 8

      #3
      Originally posted by Mr Gray
      Hello,

      You can create a session variable like so:

      Code:
      Session["Name"] = value;
      Thanks.
      how to request that.even it is simple please explain me?

      Comment

      • Shashi Sadasivan
        Recognized Expert Top Contributor
        • Aug 2007
        • 1435

        #4
        If the session variable does not exist, it will be created.
        If it exists, then it will be overwritten !
        Code:
        object o = Session["Name"];
        string name = (string)o;
        Is that what you mean by requesting?

        Comment

        • kunal pawar
          Contributor
          • Oct 2007
          • 297

          #5
          Hi

          in VB.net
          to Set Session variable
          Session.content s("Variable name")= value/ variable

          To Get Session Variable
          variable name = Session.content s("Variable name")

          In C#

          To Set Session variable
          Session.content s["Variable name"]= value/ variable;

          To Get Session Variable
          variable name = Session.content s["Variable name"];

          Comment

          • malav123
            New Member
            • Feb 2008
            • 217

            #6
            Hi,
            You can create session variable simply as,
            Session("variab lename")= value
            and in the project you can use it in any page like,
            obj.id=Session( "variablename") ...

            Comment

            Working...