Click here to Skip to main content
15,904,348 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Greetings,

Few days ago, I appeared in an interview in a software company for .net developer. There I was asked a questions that
If we close browser window without getting logout, what will happen when we provide same URL in the browser?
My answer was that user will be able to view the home page with login details instead of being prompted to provide username and password as session of the user has not ended. Login information will actually be retrieved from cookies. But it depends upon the logic we have implemented for Login. But interviewer doesn't seem be satisfied with my answer and didn't accept my answer. I am wondering what might be answer of this question. So, I need your kind guidance regarding correct answers. So please explain what I was supposed to reply.


Thanks in Advance.
Posted

The question of course was somehow unfair - as there is two answers, short and long.
The short - the one you gave - is not exactly wrong but missing a lot of things...
The long is 'it's depend' - and from there you can go into a 20 minutes explanation of needs and design and implementation and user choice and on and on...
However you may got away with 'it's depend' and pointing out that there is no ultimate solution and so there is no ultimate behavior...
 
Share this answer
 
No,
If we close the browser, the Session values will be cleared.
so if they tried to open the url in a new browser window it will prompt for the Login credentials.
Note: Across the browser Tabs,the Session values will be Common.

Your answer will be right, if the logic behind the site is using Cookies
 
Share this answer
 
Comments
Kornfeld Eliyahu Peter 26-Jan-14 5:51am    
Why exactly session values will be cleared on browser close?
Karthik_Mahalingam 26-Jan-14 6:20am    
I tried in my machine, as i set the session value in one page and closed the browser and tried to read the value from another page in new browser. it is null, more over the session i set is 20 mins as default.
any thing wrong ?
or something i missed out ?
please let me know..
Kornfeld Eliyahu Peter 26-Jan-14 6:37am    
True - and that because every new browser will open a new session with the web server, and every new session has its identifier, under which the variables stored.
But! Closing window in browser will not even hit the web server - unless you done something special - so the other session is still there and the info still can be retrieved...
So session does not cleared - you just sitting on a new session!
(The multi-tab browsing brought in some differences in how new sessions created but that's not really connected)
The fact is that the exact behavior is depends on you design - session, cookies whatsoever...
So his answer was wrong - but form as the question was phrased it's or a very smart place where they don't want someone not already experienced with all the little details of web development - or the one asked the question do not know the real answer too :-)
Karthik_Mahalingam 26-Jan-14 6:44am    
might be..
am expecting even more clear solution from other experts. will see.. :)
touseef4pk 26-Jan-14 7:28am    
Karthik when I answered my question the cookies were exactly in my mind. So what I assume is even if we open new browser window the info will be available there unless you have removed cookies from your browser. But I am curious to digging it more to make sure I really have missed something crucial.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900