Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7166105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:21:36+00:00 2026-05-28T14:21:36+00:00

A session is being passed after successful login from a aspx page to an

  • 0

A session is being passed after successful login from a aspx page to an html page, i want to be able to get the session object using JSON and modify html elements, can anyone post a simple example on how to do that using JSON ?

thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:21:36+00:00Added an answer on May 28, 2026 at 2:21 pm

    You will need to make a AJAX call from the clientside to a web service method or a page method (webmethod defined in your page).

    If you choose for the page method option your code could be something like this:

    Your code behind of your Page.aspx

        public class CustomSessionObject
        {
            public string Name { get; set; }
        }
    
        [WebMethod]
        public static object GetSessionData()
        {
            try
            {
                return HttpContext.Current.Session["THE_SESSION_VAR_YOU_NEED"] as CustomSessionObject;
            }
            catch (Exception e)
            {
               //Log Exception
    
                throw;
            }
        }
    

    I would not advise to always give back all the session vars. Make it explicit and give only back the ones you need. This way if on a later moment in time a other developer adds more user session vars they will not be returned as well. If you do this, it might be a security leak in the future.

    Using JQuery for making the AJAX call.

    var handleError = function(jqXHR, textStatus, errorThrown) {
        alert("An error occurred: " + jqXHR.responseText);
    };
    
    var handleSuccess = function(data, textStatus, jqXHR) {
        if (data && data.d) {
            alert(data.d.Name);
        }
    };
    
    $.ajax({
        url: 'Page.aspx/GetSessionData',
        type: "POST",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: handleSuccess,
        error: handleErr
    });
    

    Also read this for some more info.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some troubles using Session Variables as they are being used as Reference
session_start(); //login page if(mysql_num_rows($result) != '0'){ // If match. session_register(username); // Craete session username.
The Form variable in my form is being passed/retrieved via Session. I have a
I'm trying to use Apache::Session::Memcached in an HTML::Mason project where I'm using MasonX::Request::WithApacheSession to
Using the examples from the CGI::Session::Auth::DBI and CGI::Session::Auth pages, I have attempted to implement
session.createQuery(Select attribute from GoodsSection tgs + join gs.ascendants ags join ags.attributes attribute + where
I have another very puzzling question that has cropped up after my upgrade from
All the data is being passed as I have sufficiently tested over and over
I've got a method that is being passed a vehicleID - I need to
Session transcript: > type lookma.c int main() { printf("%s", "no stdio.h"); } > cl

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.