# Cookies? sessions? help?

**URL:** <https://www.ruby-forum.com/t/cookies-sessions-help/107968>\
**Category:** Rails\
**Created:** [June 27, 2007, 10:18pm UTC](https://www.ruby-forum.com/t/cookies-sessions-help/107968 "2007-06-27T22:18:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 27, 2007, 10:18pm UTC](https://www.ruby-forum.com/t/cookies-sessions-help/107968/1 "2007-06-27T22:18:05Z")

</div>

say i wanted for a user to go to [http://www.domain.com/intro](http://www.domain.com/intro) when they  
first hit [http://www.domain.com/](http://www.domain.com/)

subsequent visits to the site while still on the current session would  
result in just going to [http://www.domain.com/](http://www.domain.com/)

basically the user only sees [www.domain.com/intro](http://www.domain.com/intro) once, and only once…  
unless they explicitly put in the ‘/intro’ manually.

thoughts? ideas? links? tutorials?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 28, 2007, 9:57am UTC](https://www.ruby-forum.com/t/cookies-sessions-help/107968/2 "2007-06-28T09:57:20Z")

</div>

the user hits /intro for the first time in the site, or for the first  
time per session? if you want him to see /intro for the first time  
entering the site, and the next week when he comes to visit your site,  
you don’t want him to see it, you should probably cookie him.  
if not, session is the way to go.

and in the controller you’ve routed the homepage to, just do a  
before\_filter to the homepage action, and add a if session[:visited?]  
clause or something like that to do a redirect.

good enough?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 28, 2007, 4:26pm UTC](https://www.ruby-forum.com/t/cookies-sessions-help/107968/3 "2007-06-28T16:26:41Z")

</div>

On 6/27/07, mason [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> say i wanted for a user to go to [http://www.domain.com/intro](http://www.domain.com/intro) when they  
> first hit [http://www.domain.com/](http://www.domain.com/)
> 
> subsequent visits to the site while still on the current session would  
> result in just going to [http://www.domain.com/](http://www.domain.com/)
> 
> basically the user only sees [www.domain.com/intro](http://www.domain.com/intro) once, and only once…  
> unless they explicitly put in the ‘/intro’ manually.

Assuming “/” maps to action “index” and “/intro” maps to action  
“intro”, you would

def index  
unless session[:intro\_seen]  
redirect\_to :action =\> “intro”  
return  
end  
end

def intro  
session[:intro\_seen] = true  
end
