Click here to Skip to main content
15,892,575 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
is it possible to assign session["b"] to session["a"] in c#?
Posted
Comments
[no name] 19-Dec-12 0:41am    
Have you tried to assign it ??
Sharon 2 19-Dec-12 0:47am    
no i didnt assign?
Dee_Bee 19-Dec-12 1:26am    
Yes you can assign.
Christian Graus 19-Dec-12 1:34am    
You said this is an interview question. If you got this right when I asked it, I'd ask something else, I'd still find out that you have to ask on forums for answers to basic questions. You'll get a job when you know how to program, not when you know how to answer a list of questions

Hi,

Yes, You can.

Try below code.

C#
if(Session["b"]!=null)
object b = Session["b"] as object;
Session["a"] = b;

Hope this will help you.
 
Share this answer
 
If what the guy told you is the answer, then your question is amazingly clueless. If you meant to copy values between two sessions, it can be done, via the application object or the database, but anything that lives in the session, should belong to that session.
 
Share this answer
 
Comments
[no name] 19-Dec-12 1:03am    
and ya by Session[""].Copy() as well...
Sharon 2 19-Dec-12 1:21am    
this is an interview question...
Sharon 2 19-Dec-12 1:32am    
thanks to all for the answers

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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