# Set a session variable in a link\_to

**URL:** <https://www.ruby-forum.com/t/set-a-session-variable-in-a-link-to/169301>\
**Category:** Rails\
**Created:** [June 2, 2009, 3:42am UTC](https://www.ruby-forum.com/t/set-a-session-variable-in-a-link-to/169301 "2009-06-02T03:42:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JannaB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df788c/32.png) [@JannaB](https://www.ruby-forum.com/u/JannaB)\
**Post date:** [June 2, 2009, 3:42am UTC](https://www.ruby-forum.com/t/set-a-session-variable-in-a-link-to/169301/1 "2009-06-02T03:42:20Z")

</div>

I need to link\_to a particular method in a particular controller that  
needs to do something one time, from one page, and something  
dfifferent another time, from another page.

I intend to set and subsequently get a session variable to do this.  
This would require setting a session variable in the link\_to code –  
is there a way to do this? Thanks, Janna

---

<div class="post-metadata">

**Author:** ![JannaB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df788c/32.png) [@JannaB](https://www.ruby-forum.com/u/JannaB)\
**Post date:** [June 2, 2009, 4:44am UTC](https://www.ruby-forum.com/t/set-a-session-variable-in-a-link-to/169301/2 "2009-06-02T04:44:24Z")

</div>

link\_to(“my link”, my\_task\_path, :special\_needs =\> true)

That would give you params[:special\_needs]

What are the actions maybe you should have different controllers?
