HOW TO MAINTAIN SESSION VARIABLES?

8 replies
How do I get session variables in HTML Pages?
#maintain #session #variables
  • Profile picture of the author michael_gourlay
    Depends, what language are you using? Do you just want to print them out to the HTML page? If you explain a little more about what you'd like to do, perhaps we could help better.
    {{ DiscussionBoard.errors[4148044].message }}
  • Profile picture of the author Christian Little
    Originally Posted by kapsystem View Post

    How do I get session variables in HTML Pages?
    I'm going with the assumption that you are talking about PHP. And since your post is asking a different question than the subject line...


    How to Maintain Session Variables

    Put this at the top of every page BEFORE anything is outputted to the browser. That will maintain them across multiple pages.

    Code:
    <?php session_start(); ?>
    How To Get Session Variables

    This one I'm not sure if you are talking about just showing the values, or using them.

    To show the values, you can do this:

    Code:
    <?php print_r($_SESSION); ?>
    That will output all session variables to the browser so you can see their names and values.

    If you want to use them, you just reference them in an associative array:

    Code:
    <?php
      echo $_SESSION["something"];
    ?>
    That code would output the value of the session variable "something" to the browser.
    {{ DiscussionBoard.errors[4149234].message }}
  • Profile picture of the author AdWorkMedia
    Could also use cookies with JavaScript if you can't use PHP, but I would definitely recommend PHP sessions as they are more secure. That's a nice overview on them Christian Little!
    Signature


    AdWork Media » Global Affiliate Network & Content Locking Solutions

    Custom Platform, Flexible Lockers, Offers For Every Country
    {{ DiscussionBoard.errors[4150030].message }}
  • Profile picture of the author kapsystem
    HI

    For your information i want to do changes in asp.net for html page.

    when i am accessing aspx page my session is avail,but if i switch to html page from aspx page the session is got expired.It shouldn't happen like this.what is the right solution to keep session alive,though whatever switching happen between aspx page and html page?


    With Best Regards
    Natarajan R (UI Designer)
    KAPSYSTEM (kapsystem.com)
    {{ DiscussionBoard.errors[4151564].message }}
  • Profile picture of the author kingdomvision2
    aspx when I access my session is available, but if I switch to the html page from aspx page session has expired.
    {{ DiscussionBoard.errors[4151720].message }}
  • Profile picture of the author myolay21
    Normally SessionID is generated from Server Side and store in Client cookie. Then everytime the client makes a request to the server the SessionID is used to authenticate the existing session for the client.

    For your case aspx page can call to server side function to check the SessionID passed from client side and get session variables.

    I don't think HTML support the session.

    If you really need to get session variables on html you need to use AJAX and fetch session variables from html page.
    Signature

    If you catch two Rabbits you will lose them both.

    {{ DiscussionBoard.errors[4151742].message }}
  • Profile picture of the author hocine
    Depends, what language are you using? Do you just want to print them out to the HTML page? If you explain a little more about what you'd like to do, perhaps we could help better.
    {{ DiscussionBoard.errors[4160028].message }}
  • Profile picture of the author AdWorkMedia
    Why are pages being switched from asp to html? You could keep it all in asp and avoid the session issue.
    Signature


    AdWork Media » Global Affiliate Network & Content Locking Solutions

    Custom Platform, Flexible Lockers, Offers For Every Country
    {{ DiscussionBoard.errors[4166541].message }}

Trending Topics