Note that there are some explanatory texts on larger screens.

plurals
  1. PORails 3: How to tell if a user has visited a page before?
    primarykey
    data
    text
    <p>I have a Rails app (using Authlogic for authentication) with a simple jquery animation that I only want to run once upon first page load. I know that the key is to check cookies or something to see if the user has visited the page before. Please forgive my n00bness, I know little to nothing about HTTP cookies or sessions.</p> <p>So, what's the best way to see if a visiting user (even if they haven't logged in) is viewing a page for the first time? </p> <p><strong>EDIT:</strong> Ok, so I realize I wasn't being entirely clear.</p> <p>I've spent hours looking at similar questions and reading the Rails API Docs for cookies and sessions and I still can't visualize how to implement a <strong>visited?</strong> function for each page in my site that will only be set to "true" after the user has visited the page the first time. I looked at the supposed "duplicate" question <strong><a href="https://stackoverflow.com/questions/4988300/rails-detect-if-users-very-first-visit">Rails Detect If User's Very First Visit</a></strong> and the respective answers and still can't figure it out. </p> <p>Here's my "Pages" controller:</p> <pre><code>def home @title = "Home" end def contact @title = "Contact Us" end </code></pre> <p>dd</p> <p>And my jquery javascript that does a simple animation:</p> <pre><code>$(document).ready(function() { if (!$.cookie('visited')) { $('.title .flying-text').css({opacity:0}); $('.title .active-text').animate({ opacity:1, marginTop: "-150px", }, 5000); } }); </code></pre> <p>I only want it to show if the user HAS NOT visited the page before. I have no idea how to properly set a cookie in Rails, nor where to put it, nor how to make sure that the animation script can access that exact same cookie value. Can someone give me a hand?</p> <p>~Dan</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload