.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Common session for different browser instance

Posted By:      Posted Date: August 25, 2010    Points: 0   Category :ASP.Net

Hello everyone,

I am working on a website which uses a common database shared by another 2-3 websites.  Now i am having a requirement that whenever a user clicks a link provided on another website and comes to my website and if the user is already logged in to my website then my website should not ask him to login again it should by pass the login page and show the next page.

Here the problem is i am not able to get the session objects in newly opened browser window even if the user is already logged in to my website in another browser window. I am not sure but i thing IE uses two different processes for two different browser instance and because of that i am not getting the session objects required.

Deos anyone have some idea on my problem.

Note: I can not ask the another website vendor to pass anything as a querystring.

View Complete Post

More Related Resource Links

How to detect and prevent new browser instance


Hi Folks,

I have a problem w/ a web app which is probably fairly common, but I cannot find any solutions anywhere. Hopefully someone will have an idea.

The web app in question provides a UI for editing a client (in the business sense, not the browser sense), identified by a ClientID.  I store the ClientID in Session, which gets passed from page to page, along with a number of other pieces of data in Session.  Works great.

The problem is that if the user opens a new browser window using Ctrl N or File->New Window (in IE), the new window comes up with the same page as the current page, with the same session info. Then if the user navigates to a different client in the 2nd window, the ClientID in session refers to the new client. If they go back to the original browser window and save, the original client gets saved using the 2nd ClientID, and all hell breaks loose, because now the data from the two jobs are intertwined.

I have enabled trace and verified that the new browser window uses the same SessionID as the original.  If an entirely new instance of IE is opened, it has a different SessionID, so is not a problem.  I have not yet investigated other browsers, such as Chrome or Firefox.

Is there any way to determine if a browser instance is opened for a web app which is already open in

Session Object not set to an instance.....

Hello all, Please tell me if I have made a mistake in the following code. It is part of a class that cycles through various conditions to return a value to aspx page. I get null exception when it hits the session variable. I even declared the session variable in global.asax, and thought that I was checking for null value correctly. Obviously I haven'tImports Microsoft.VisualBasic Imports System.Linq Imports System.Web Imports System.Web.Services Imports System.Web.HttpContext Public Class OrderNumber Public Shared Function GetOrderNumber() As String ' ''//Sets OrderNumber if it exists If Not HttpContext.Current.Request.QueryString("OrderNumber") Is Nothing Then Return CType(HttpContext.Current.Request.QueryString("OrderNumber"), String) ElseIf Not HttpContext.Current.Session("OrderNumber") Is Nothing Then Return CType(HttpContext.Current.Session("OrderNumber"), String) ElseIf Not FindExistingOrder() Is Nothing Then Return FindExistingOrder() Else : Return "" End If End Function   Thanks, I am pretty well stumped. Have a good evening.

Open browser with 2 session tabs from C#



I have a button control where I retreive 2 strings with 2 URL like in the code below.

What I wonder how it is possible to do, is how to open up 1 browser window with 2 Session Tabs where 1 Tab is http://www.google.com and the other http://www.yahoo.com

How can this be possible to do from code behind (C#)?

    protected void Button1_Click(object sender, EventArgs e)
		String URL1 = "http://www.google.com";
		String URL2 = "http://www.yahoo.com";

		//How to open up a browser with two session tabs with each URL in each?


is session shared within multiple browser windows (not tab)


Hi guys,

Really confused on this... let me explain the scenario.

i have a application on .net 2.0 .

once user is logged in, various session variables are stored for that users profile information (normal stuff). when user open a browser window and after doing some operation, closes the browser window directly.

and then reopen new window and try to access homepage of same application... he is presented with profile of the user which was logged in before (and widnow was shut down)

is this behaviour normal and common across all IE versions?

this behaviour is not consistent.... sometimes, its showing homepage of old user and sometimes its  showing login page (as if session is invalidated)

is there any way to abandon all session if browser window is closed (apart from capturing browser window close event)

hope i get some replies on this...

Session Ending or FormsAuthentication problem after the browser tab closing


In my project user logs in the site with login.aspx page. Then user is redirecting to homepage (anasayfa.aspx)

User close the browser tab (not the browser) then user tries to open the site again and the page is default.aspx

Default.aspx is useless in my project. Host area needs a default.aspx, index.html like something and I added this default aspx.

I want:

After user close the browser tab, if he/she wants to open the site again, the first page must be his/her homepage not default.aspx

I didn't use asp.net membership provider or anything like that.

This is my login.aspx page code:

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        SqlConnection con = new SqlConnection();
        con.ConnectionString = cnnstr;
        SqlCommand cmd = con.CreateCommand();
        cmd.CommandText = "Select Roles,UserId,UserName,Sifre,AccountType From ProfilBilgileri Where UserName = @txtLoginUserName AND Sifre = @txtLoginSifre and Durum=1";
        cmd.Parameters.Add("@txtLoginUserName", SqlDbType.NVarCh

session variable and multiple web application instance


 I have a web application using window authentication. There are a search page and a edit page in the application. 

In search page, user can enter some search criterias in the textboxes and the search result will be displayed in the gridview by clicking the "Search" button. User can select any row from the gridview and it will take him to the edit page. 

 In the edit page, there is a "Back" button to take the user back to the search page. I use session variables to remember what the search criterias the user entered in the textboxes and what page number the user was in the gridview. So when the user goes back to the search page, the textboxes are pre-populated with the search criterias and the gridview is displayed in the correct page number.

The problem is:

If user1 opened one browser window and did a search using search criterias1, then user1 opened a 2nd browser window and did a search using search criterias2. When the user1 went back to the search page from the edit page using the first browser window, all the textboxes and page numbers are from the 2nd browser window, instead of the 1st one.

Can anyone explain this problem to me and how to prevent it? It will be helpful too if you can give me some links about the similar problem.

Session time-out : object reference not set to an instance...


I noticed that when i am debugging my web application in Visual Studio 2005 using IIS, after about 10-15 minutes of inactivity, when I do something in the application such as a postback, I get an immediate error saying: "object reference not set to an instance" and my code breaks somewhere.

Is my assumption correct that this is because my session has timed out? ( i do have a 15 minute default session time)

my next question is, how do I display or set a way so that like many other pages, when the session has expired, a message will say: "This page must be refreshed" or "Your session has expired, click okay to refresh page" and start over again?


FormsAuthenticationTicket issues in firefox(multiple instance of browser)


Hi All,

I am using forms authentication in asp.net application. This is working fine in internet explorer. Opening application in firefox is also fine but when i login in second instance of firefox, application in first instance logs out. Following is my code for creating ticket and cookie.

FormsAuthenticationTicket objTicket = new FormsAuthenticationTicket(1, sUserName, DateTime.Now, DateTime.Now.AddMinutes(60), false, "");

HttpCookie objCookie = new

Session Timeout in WPF browser application


Hi All,

I have to design a web browser application in WPF with a session timeout facility. The requirement to provide a session timeout after 1 hours. How can this be achieved? Also i need to implement login based menu access levels in this application. How can i achieve both these?


End Session When Browser Closed


Hi, I am quite new to asp.net and web tech.

I created a site something like bookstore, and now I am creating shopping cart for it.

I used datatable which i store in session for store shopping cart data.

The problem is that, I put some items in cart and then close the browser immediately and next time when i open it the data are stills there unless the session is expire.
I like to abandon the session when user close the browser.
Is there any solution for it and is this a good way to create my shopping cart?

Thx in advance.


Session expiry on closing browser window

The article Session expiry on closing browser window was added by RustyIron on Saturday, February 26, 2011.

Ever wondered what occurs when a user closes his browser window. For the time, the user was interacting with a site, his session was active and everything was going smooth.But how does our player ("Server" , here) come to know that a user has

Set an instance Session object



When im running unit testing no an action in the homecontroller i get the following error: 

"Test method WhatsForLunch.Tests.Controllers.HomeControllerTest.Test_Index threw exception: System.NullReferenceException: Object reference not set to an instance of an object."

I know what is causing the error, which is the Session object that i set false and null

 at application start and is further used to track user and hold user information when a user is logged in.

How do i set the object to an instance so that i can perfrom unit testing to the action??



thx in Advance

Kill session when user closes the browser



I have a requirement from client that to show the concurrent users.

They are using one username and password at different instances. As we need to track the concurrent users, I have wriiten in Global.asmx file for Session_start and session_End , But still showing a differentt result.


So, we have choosen database and when the user logins successfully , count is tracked in the database. And when user loguts count is decreased.

But, we are facing a problem like when user closes the browser how can we end the session and decrease the count in the database. And if be abruptly when he closes the browser or if session gets timed out count should be decreased.

MS SQL Server: Disconnect Users From Database - Kill User Session

If you ever wanted to restore your database from a SQL backup file (.bak), but there are still users connected to your database, the backup operation will fail causing the error: Exclusive access could not be obtained because the database is in use.

How to setup a Mobile Browser Emulator in Windows Mobile 6:

In the following tutorial, I cover the process of Setting up Windows Mobile 6 for Mobile Browser Emulation using the Microsoft Device Emulator. This enables a user to experience Windows Mobile 6 on a PC via Emulation without even owning a Windows Mobile 6 product. It can be a great way to test drive Windows Mobile 6 before purchasing a product with it installed. In our case, it allowed us to Emulate Windows Mobile Browsing so that we could optimize our sites for the Mobile viewing audience. Installation and Emulation is simple and fairly straight forward.

*.axd script references not being rendered to browser


I'm running VS2010 with .net 4.0, and am running into issues with the .net ajax script tags mysteriously not being rendered to the browser.

So far I've reduced it to a scenario where I set the DataSourceID property of a databound control.  More specifically, I've only tested it on a Gridview and a DropDownList.

This can be reproduced fairly easily on my machine by following these steps:

1. Create a new empty Web Application Project

2. Create a new Web Form

3. Add a ScriptManager inside the form

4. Add a DropDownList and a DataSource (I used an ObjectDataSource)

5. Set the DataSourceID property of the DropDownList to the ID of the DataSource.  This can be done either declaratively on the .aspx page, or in the code behind in the aspx.cs page, and both produce the same results.

6. Open the page in a browser and watch as you get a javascript error stating "Sys is not defined" and notice that the page source contains no script tags referencing *.axd scripts.

Here's my source code showing my set up:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ScriptResourceFAIL.Default" %>


WebDev.WebServer.exe has encounted a problem and needs to close when trying to view page in browser


Hi, whenever I load an aspx page in vwde2008, I get the message in the subject of this post.  After I click Ok on that, I get a dialog box, Unable to Connect to the ASP.Net development center.  What can I do to troubleshoot?

I am using Windows XP SP3, vwde2008 with SP1, on a HP desktop.  Also using Office 2003 if that is relevant at all.

Thanks, Justin

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend