Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
is it possible to assign session["b"] to session["a"] in c#?
Posted 18-Dec-12 18:40pm
Comments
Krunal Rohit at 19-Dec-12 0:41am
   
Have you tried to assign it ??
Sharon 2 at 19-Dec-12 0:47am
   
no i didnt assign?
Dee_Bee at 19-Dec-12 1:26am
   
Yes you can assign.
Christian Graus at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
Yes, You can.
 
Try below code.
 
if(Session["b"]!=null)
object b = Session["b"] as object;
Session["a"] = b;
Hope this will help you.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
Comments
Krunal Rohit at 19-Dec-12 1:03am
   
and ya by Session[""].Copy() as well...
Sharon 2 at 19-Dec-12 1:21am
   
this is an interview question...
Sharon 2 at 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
0 Nirav Prabtani 268
1 OriginalGriff 217
2 Mika Wendelius 185
3 CPallini 170
4 _Amy 170
0 Nirav Prabtani 284
1 OriginalGriff 217
2 Mika Wendelius 185
3 _Amy 170
4 CPallini 170


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 19 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100