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

andrecuellar's avatar

How to set a session value in ajax

Hello, it's possible to set a session value directly in ajax?

example: I want to add this key and value in session

Session(['templateType' => $templateType]);

but in Javascript, using ajax

I have this

          $.ajax({
                url: "set_session.php",
                data: { "templateType": {{\App\Enums\TemplateType::PLACE}} }
          });

but I get 404 error

0 likes
2 replies
jlrdw's avatar

You can pass values, and set them server side.

1 like
dennisprudlo's avatar

Apparently /set_session.php does not exist, hence the 404

1 like

Please or to participate in this conversation.