ycv005

ycv005

Why getting get_session error when using put_session? See this screenshot. I am modifying the conn in my job_view.ex file. Also, could I change the conn variable anywhere like(view, controller, model or more).?

Showing Posts 1 to 8

peerreynders

peerreynders

It makes more sense to copy the full error text into your topic - as it is most of the pertinent information is missing from the image you linked to.

The only useful bit of information is

no function clause matching in Plug.Conn.get_session/1

I suspect that it fails here:
https://github.com/elixir-plug/plug/blob/v1.8.2/lib/plug/conn.ex#L1590-L1597

which suggests that the conn argument you pass isn’t actually a %Plug.Conn{} struct (though it would seem odd that it gets passed conn.private).

Though additional error information may give some more insight.

From the limited information on the screenshot I’m not necessarily convinced that the error originates from the code you show (again the relevant error information is missing) - given how IO works, position of errors relative to IO.puts output isn’t necessarily a reliable indicator of the actual location of where the error occurs.


Unrelated - put_session/3:

The key can be a string or an atom, where atoms are automatically converted to strings.

So "share_job_opening_description" as a key would be clearer than :share_job_opening_description (which is converted to the string anyway).

ycv005

ycv005 OP

I think, actually, it is a socket (full screenshot). So, I may conclude that conn is my socket. Inspect conn before any modification, following things I get

%Phoenix.LiveView.Socket{.......

So, How can I modify the “share_job_opening_description”?

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

@ycv005 In the future please copy and paste the actual text instead of using screenshots. If we want to highlight important text it forces us to type it by hand.

You can’t modify the session from a live view right now. It’s probably possible in theory, since javascript is allowed to change cookies, but phoenix would have to create hooks for it.

ycv005

ycv005 OP

Thanks will keep in mind about the code snippet.
But I can use the assign

  def get_copy_link_url(conn, job_opening, host, user) do
    conn
    |> assign(share_job_opening_description: job_opening.name)
    IO.puts("++++++++++++testconn")
    IO.inspect(conn)

Getting Error- undefined function assign/2

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Two things:

  1. the function is 3 arity not 2, conn |> assign(: share_job_opening_description, job_opening.name)
  2. the conn is immutable, you need to rebind it:
conn = assign(conn, :share_job_opening_description, job_opening.name)
ycv005

ycv005 OP

Used your code conn = assign(conn, :share_job_opening_description, job_opening.name) . Getting error- undefined function assign/3.

peerreynders

peerreynders

My impression was that we are dealing with a liveview socket

def get_copy_link_url(socket, job_opening, host, user) do
    socket
    |> assign(share_job_opening_description: job_opening.name)
    IO.puts("++++++++++++testconn")
    IO.inspect(socket)
  • For assign/2, assign/3 to work use Phoenix.LiveView is necessary

@ycv005:
The bigger question is: to what end are you doing this? What greater objective are you trying to accomplish?

Because right now this feels like an XY Problem.

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Please show the full module that this is in.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews