locked
session null RRS feed

  • Question

  • User-119345712 posted

    why it happen when i redirect user to PAYPAL's sandbox (https://www.sandbox.paypal.com)  from my localhost then after returning to .aspx page (successful.aspx), it losses session, 

    e.g. SESSION["tempUser"], it works on everypage but not on Successful.aspx page, it returns null, i am working on this error for 2 weeks, but no progress, 

    Tuesday, December 18, 2012 8:03 AM

All replies

  • User-1716253493 posted

    Maybe you have wrong event code that clear the session.

    Tuesday, December 18, 2012 8:16 AM
  • User-119345712 posted

    thanks, no but thats not the problem , 

    do u have any other alternative ? 

    Tuesday, December 18, 2012 8:39 AM
  • User-1822989843 posted

    Try something like this:

            public string GetCartId()
            {
                if (HttpContext.Current.Session[CartSessionKey] == null)
                {
                    if (!string.IsNullOrWhiteSpace(HttpContext.Current.User.Identity.Name))
                    {
                        HttpContext.Current.Session[CartSessionKey] = HttpContext.Current.User.Identity.Name;
                    }
                    else
                    {
                        // Generate a new random GUID using System.Guid class.     
                        Guid tempCartId = Guid.NewGuid();
                        HttpContext.Current.Session[CartSessionKey] = tempCartId.ToString();
                    }
                }
                return HttpContext.Current.Session[CartSessionKey].ToString();
            }
    

    http://www.asp.net/web-forms/tutorials/aspnet-45/getting-started-with-aspnet-45-web-forms/checkout-and-payment-with-paypal

    http://www.asp.net/web-forms/tutorials/aspnet-45/getting-started-with-aspnet-45-web-forms/shopping-cart

    Tuesday, December 18, 2012 9:11 AM
  • User-119345712 posted

    same problem bro !

    Tuesday, December 18, 2012 9:36 AM
  • User-650628323 posted

    Hi,

    e.g. SESSION["tempUser"], it works on everypage but not on Successful.aspx page, it returns null, i am working on this error for 2 weeks, but no progress, 

    Could you share the corresponding code? I want to test locally.

    Best wishes,

    Thursday, December 20, 2012 9:54 PM
  • User1849564856 posted

    hi

               check ur browser, may be paypal is returning u on different browser. for session browser must be same

    Thursday, December 20, 2012 10:58 PM
  • User-119345712 posted

    Redirection Page:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="paypalRedirection.aspx.cs" Inherits="paypalRedirection" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Payment</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
         <h4> Congrats <b> <%# Session["tempSubAdminName"]%>  </b>, Your basic informaton has been submitted , For full activation you need to pay via paypal. Please click the PayPal icon given below. </h4>
        </div>
        <div>
         <asp:HyperLink ID="homeBtnImage" runat="server" ImageUrl="~/btnPayPal.gif"
              NavigateUrl= "https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_xclick&business=smile2_1355775057_biz@yahoo.com&item_name=MemberShip&amount=20&currency=USD&return=http://127.0.0.1:57135/Online%20Recruitment%20System-Final/paymentSuccessful.aspx?emailAdmin='1234' &cancel_return=https://www.google.com/" >PayPal</asp:HyperLink>
        </div>
        <h6>Or if you don't have paypal account, click <asp:HyperLink ID="paypalSite" runat="server"
            NavigateUrl="https://www.sandbox.paypal.com/" >here</asp:HyperLink> </h6>
        </form>
    </body>
    </html>
    
    

    Return to this page if successful:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="paymentSuccessful.aspx.cs" Inherits="paymentSuccessful" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Payment Successful</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
         <h5> Dear <%# Session["tempSubAdmin"] %>, You have successfully registered , Please wait for the approval by admin. </h5>
        </div>
        </form>
    </body>
    </html>
    

    and yes i am binding data, on .cs page by using Page.DataBind();

    the page where session begins :

    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    try
            {
                con.Open();
                com.ExecuteNonQuery();
                Session["tempSubAdmin"] = txtemail.Text;
                Session["tempSubAdminName"] = txtfullname.Text;
                Response.Redirect("paypalRedirection.aspx?subAdmName=" + txtfullname.Text);
                
            }
            catch (Exception ex)
            {
                Response.Write("Error:" + ex.Message);
            }
            finally
            {
                con.Close();
                //Session["tempSubAdmin"] = txtemail.Text;
                //Session["tempSubAdminName"] = txtfullname.Text;
                //Response.Redirect("paypalRedirection.aspx?subAdmName=" + txtfullname.Text);
            }
    .
    .
    .
    .

    and 

    Session["tempSubAdmin"]  works on every page but not which i mentioned in return path, after returning it losses
    Session["tempSubAdmin"]. 



    Saturday, December 22, 2012 12:16 PM
  • User-119345712 posted

    no,same browser 

    Saturday, December 22, 2012 3:34 PM
  • User1779468316 posted

    If you are using cookieless sessions (and this problem is related to that) you need to place the session variable on the return url before you send it.

     

    Saturday, December 22, 2012 3:38 PM
  • User-119345712 posted

    i also tried that but no progress

    Saturday, December 22, 2012 6:01 PM
  • User1779468316 posted

    Then I would talk with the people you are sending the return url to. I would mention them by name if I remembered the first part of this message thread.

     

    Saturday, December 22, 2012 6:05 PM
  • User-119345712 posted

    the problem is that name isnt a unique field , 

    Sunday, December 23, 2012 6:20 AM
  • User-1011137159 posted

    That might be the problem in your browser setting can you try it in other browser or different machine

    Also which session mode you using? cookie less or with cookie,

    Tuesday, December 25, 2012 6:59 AM
  • User-119345712 posted

    cookie less

    Tuesday, December 25, 2012 7:27 AM
  • User1779468316 posted

    That's what I was thinking when I suggested that you talk to the people that you are sending the return url to. They are apparently stripping the authentication string from the url you are sending. That needs to be correct on their end of things. There is absolutly NOTHING that you can do about it from your end.

     

    Tuesday, December 25, 2012 8:02 AM
  • User-1011137159 posted

    cookie less

    That is the issue, in any cross plateform redirection you can not use cookie less session because that is stored in your URL and when you come back from paypal then it away. so your session id is not found in URL so all session value returns as null and system generate new session id but your old is gone...

    So I suggest use normal session rather then cookie less/

    Tuesday, December 25, 2012 8:45 AM
  • User-119345712 posted

    same problem, i did what u said !

    Tuesday, December 25, 2012 11:10 AM