Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hjortur17's avatar

Does Laravel Session has a unique key?

Does a session have a unique key? And if so, how do I access it?

0 likes
10 replies
hjortur17's avatar

So I need to store a booking in the session and then send a session ID over to the payment provider, and after the customer pays, then they will redirect to my site, match up the ID's and continue with the booking.

Ap3twe's avatar

An example of finding a session of the created_id. This looks for the key created_id

        $project = Project::where('user_id', auth()->id())->find(session('created_id'));

        return view 

    }```

raw php 
```<?php
function session(
    $key = null,
    $default = null
) { }```
hjortur17's avatar

Just for testing, I'm doing it like this:

$form = collect($request->all());

Session::put('form', $form);

return $request->session()->getId();

return session('form');

And this is just for testing, I was thinking to generate a 30 letter word and hash it and store it in the session, and then check if they are the same.

jlrdw's avatar

You asking a pretty basic question about session which at the state you are at doing eCommerce you should know already

If you recall in another discussion another user sort of asked you to slow down and learn some stuff without advancing too fast.

It would just be a good idea to learn some of these basic concepts first.

Of course each user session is unique to that logged in user.

hjortur17's avatar

In my case, I don't have any logged-in user.

jlrdw's avatar

A created session is unique to that session and that browser.

hjortur17's avatar

And how can I get a data from that session when a customer comes back to the site after a redirect from another site.

jlrdw's avatar

Most gateways will return to your site with a URL you specify, in that URL have the correct information to continue whatever you need to continue with.

You would probably benefit from looking over several different Gateway apis and how they work.

1 like
hjortur17's avatar
hjortur17
OP
Best Answer
Level 14

I created my own session key to send over to the payment provider

Please or to participate in this conversation.