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

  • SEARCH
  • Home
  • 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 711893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:47:14+00:00 2026-05-14T04:47:14+00:00

I need to transfer a user to a page which requires session data which

  • 0

I need to transfer a user to a page which requires session data which is stored within a different session.

Is it possible in some cases to migrate the session data by setting the session cookie on the user’s browser?

Currently I have no workaround, and using session data seems like the only option I have at the moment.

  • 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-14T04:47:14+00:00Added an answer on May 14, 2026 at 4:47 am

    Is it possible in some cases to
    migrate the session data by setting
    the session cookie on the user’s
    browser?

    Sure you can. Simply set a new cookie and redirect. You will have to do this server-side. Setting a session cookie client-side will be problematic.

    const string sessionStateCookieName = "ASP.NET_SessionId";
    string sessionId = "some session id";
    
    HttpCookie cookie = new HttpCookie(sessionStateCookieName, sessionId) { Path = "/", HttpOnly = true };
    Response.Cookies.Remove(sessionStateCookieName);
    Response.Cookies.Add(cookie);
    
    // force a redirect to complete session switch
    Response.Redirect(Request.Path);
    

    You can expand on this. Here is a working example .aspx page. To switch sessions, simply add a url param ‘sessionId’.

    <%@ Page Language="C#" AutoEventWireup="true" %>
    
    <script runat="server">
        // this is the method that does the magic
        protected override void OnPreInit(EventArgs e)
        {
            var sessionId = Request["sessionId"];
    
            if (!string.IsNullOrEmpty(sessionId))
            {
    
                // this could be found via reflection if different sessionstate cookie name is used in config
                const string sessionStateCookieName = "ASP.NET_SessionId";
    
                HttpCookie cookie = new HttpCookie(sessionStateCookieName, sessionId) { Path = "/", HttpOnly = true };
                Response.Cookies.Remove(sessionStateCookieName);
                Response.Cookies.Add(cookie);
    
                // force a redirect to complete session switch
                Response.Redirect(Request.Path);
            }
    
        }
    
        // the rest of this script is just demo code 
    
        protected void Page_Load(object sender, EventArgs e)
        {
            CurrentSessionIdLabel.Text = Session.SessionID;
        }
    
        protected void SwitchSessionButton_Click(object sender, EventArgs e)
        {
            // this is the session we wish to switch to 
            string switchToSessionId = SessionIdTextBox.Text;
            Response.Redirect(Request.Path + "?sessionId=" + Server.UrlEncode(switchToSessionId));
        }
    
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <div>
            Current SessionId<br />
            <asp:Label ID="CurrentSessionIdLabel" runat="server"></asp:Label>
            <br />
            <br />
            <asp:Label ID="Label1" runat="server" Text="Desired SessionId"></asp:Label>
            <br />
            <asp:TextBox ID="SessionIdTextBox" runat="server"></asp:TextBox>
            <br />
            <asp:Button ID="SwitchSessionButton" runat="server" Text="Switch Session" OnClick="SwitchSessionButton_Click" />
        </div>
        </form>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 368k
  • Answers 368k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer To start with you have styles in the main.css file… May 14, 2026 at 6:03 pm
  • Editorial Team
    Editorial Team added an answer Git commands like pull don't really work with rebases. Let's… May 14, 2026 at 6:03 pm
  • Editorial Team
    Editorial Team added an answer The commands from rc.status are actually SuSe specific I think.… May 14, 2026 at 6:03 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.