Click here to Skip to main content
12,999,653 members (45,766 online)
Rate this:
Please Sign up or sign in to vote.
See more:
is it possible to assign session["b"] to session["a"] in c#?
Posted 18-Dec-12 18:40pm
Krunal Rohit 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
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


Yes, You can.

Try below code.

object b = Session["b"] as object;
Session["a"] = b;

Hope this will help you.
Rate this: bad
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.
Krunal Rohit 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

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 19 Dec 2012
Copyright © CodeProject, 1999-2017
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