how to pass session values between two applications

Posted by Shubhashree under ASP.NET on 7/10/2010 | Views : 12810 | Status : [Member] | Replies : 2
i have 2 applications where session [ login user] has to be passed from 1st application to the second application.
in my 1st application i have a querystring which holds the redirect url to the next application with the session values[ login user].
the file is redirected to 2 nd appliaction and the session is becoming null[ login user].
can you please guide me along with steps which will be very useful on how to get the session values[ login user] to the 2 nd application. as soon as possible.


Posted by: Kishork80 on: 7/10/2010 [Member] Starter

This is related to the concept of sign-on (SSO).You can do it easily if you are using 2.0/3.5/4.0

Cookied Cross-Application Behavior
You can use diff applications to the cookieless sample to also show cross-application redirects in
the cookied case. Again using two sample applications (App1 A and AppB), both applications need to share a common
<forms cookieless="UseCookies" enableCrossAppRedirects="true"
To simulate isolation of the forms authentication cookies, each application explicitly sets the path attribute
as shown above.

Because this sample uses cookies, the path attribute prevents the browser from
sending the forms authentication cookie for one application over to the second application. Remember
that setting the path attribute only takes effect when using cookied modes (for example, setting the path
attribute would have no effect on the previous cookieless example). For now, we will use the same
redirection helper as we did earlier, and pages in both applications will issue a Response.Redirect to
get to the second application.
//First application button click
FormsAuthentication.RedirectFromLoginPage("testuser", false);

-Hope this works.cheers!
Kishor Kumar

kishor kumar

Shubhashree, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhilan on: 7/11/2010 [Member] Starter

create temp table in SQL while redirect to another application store the values into temp table and retrieve the session value and assign in the 2nd application session.


DB column=Session["Username"]

in 2nd application

if(querystring("link") =="fromApp1")
SEssion["Username"]= retrieve from DB.

Make sure you store with some uniqueidentier values thata pass in querystring and retrieve based on that

Shubhashree, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response