title: lost the session data after redirecting to stripe
body: <p>I am creating a food ordering system in spring MVC with stripe payment integration. when I am trying to get the attribute from session inside the webhook controller which I had set in it previously I am getting null. why?</p>
  <p>and most importantly how to solve it?</p>
  <p><strong>edit:</strong></p>
  <p>This is my payment-intent controller which is called by a client.js file, now here I set the items in session and this controller returns the client secret id generated by the stripe to the client.js , now client.js call the stripe and makes a successful payment and on payment confirmation stripe sends me a webhook on my localhost endpoint with charge.succeeded event. Now to handle that event I need session attributes but I am unable to get them from the session as it returns null.</p>
  <p><strong>Payment-Intent Controller</strong></p>
  <pre class="lang-java prettyprint-override"><code>@RestController public class PaymentController {
      @PostMapping(&quot;/create-payment-intent&quot;)
      public CreatePaymentResponse createPaymentIntent(@RequestBody CreatePayment createPayment, 
      HttpServletRequest req)
          throws StripeException {
  
      HttpSession session = req.getSession();
  
      ArrayList&lt;String&gt; items = new ArrayList&lt;&gt;();
      JsonItem[] jsonItems = createPayment.getItems();
      for (JsonItem jsonItem : jsonItems) {
          items.add(jsonItem.getItemid());
      }
  
      session.setAttribute(&quot;pnames&quot;, items);
  
      Float amount = Float.parseFloat(createPayment.getAmount());
      System.out.println(amount.longValue() * 100l);
      PaymentIntentCreateParams createParams = new PaymentIntentCreateParams.Builder()
              .setCurrency(&quot;INR&quot;)
              .setAmount(amount.longValue() * 100L)
              .setDescription(&quot;product's amount&quot;)
              .build();
  
      PaymentIntent intent = PaymentIntent.create(createParams);
      CreatePaymentResponse paymentResponse = new CreatePaymentResponse(intent.getClientSecret());
      return paymentResponse;
  }
  }
  </code></pre>
  <p><strong>This is my Webhook Controller</strong></p>
  <pre class="lang-java prettyprint-override"><code>    @RestController
      public class StripeWebhookController {
  
      @Autowired
      private FoodhubServiceImpl service;
      
      @Autowired
      private Payment payment;
      
      private String endpointSecret=&quot;some endpoint secret&quot;;
      
      
      @PostMapping(&quot;/foodhub/endpoint&quot;)
      public String handleStripeEvents(@RequestBody String payload, @RequestHeader(&quot;Stripe-Signature&quot;) String sigHeader,HttpServletRequest req) {
          
                  HttpSession session = req.getSession();
                  
                  @SuppressWarnings(&quot;unchecked&quot;)
                  ArrayList&lt;String&gt; arr = (ArrayList&lt;String&gt;) session.getAttribute(&quot;pnames&quot;);//null
                  System.out.println(arr.get(0));//null pointer exception
                  
                  if(sigHeader == null) {
                      return &quot;&quot;;
                  }
                  
                  Event event; 
        
                  try {
                      event = Webhook.constructEvent(
                          payload, sigHeader, endpointSecret
                      );
                  } catch (SignatureVerificationException e) {
                      // Invalid signature
                      System.out.println(&quot;Webhook error while validating signature.&quot;);
                      System.out.println(e);
                      return &quot;&quot;;
                  }
                  
              // Deserialize the nested object inside the event
              EventDataObjectDeserializer dataObjectDeserializer = event.getDataObjectDeserializer();
              StripeObject stripeObject = null;
              if (dataObjectDeserializer.getObject().isPresent()) {
                  stripeObject = dataObjectDeserializer.getObject().get();
              } else {
                  // Deserialization failed, probably due to an API version mismatch.
                  // Refer to the Javadoc documentation on `EventDataObjectDeserializer` for
                  // instructions on how to handle this case, or return an error here.
              }
              // Handle the event
              switch (event.getType()) {
                  case &quot;payment_intent.succeeded&quot;:
                      PaymentIntent paymentIntent = (PaymentIntent) stripeObject;
                      System.out.println(&quot;Payment succeeded for   &quot;+paymentIntent.getAmount());
                      System.out.println(&quot;payload is : &quot;+payload);
                      handlePaymentIntentSucceeded(paymentIntent);
                      // Then define and call a method to handle the successful payment intent.
                      break;
                  default:
                      System.out.println(&quot;Unhandled event type: &quot; + event.getType());
                      break;
              }
              return &quot;200&quot;;
      }
  
  
      private void handlePaymentIntentSucceeded(PaymentIntent paymentIntent) {
          
          //do some stuff here    
      
      }
  }
  </code></pre>