Ruby on Rails Sunday, August 24, 2014

Colin Law wrote in post #1155762:
> On 23 August 2014 06:32, Bharath Neo <lists@ruby-forum.com> wrote:
>> The problem is that I want to hold sessions who have not logged out. And
>> clear sessions who have not logged in. Sessions are created
>> automatically by rails when the login page loads itself.
>
> Sorry, don't understand. Can you clarify what you mean by 'logged
> out'? I assumed you meant users that have clicked on the 'logout'
> link.
>
> Colin

Okie. This is what I see from how its happening:

1. There is a login page
2. When login page is loaded I see an entry for a session put in.

+-----+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+---------------------+---------------------+
| id | session_id | data
| created_at | updated_at |
+-----+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+---------------------+---------------------+
| 172 | 683aeb1fec89147c16db6ffb8614d915 |
BAh7BiIQX2NzcmZfdG9rZW4iMUVNN1ZVSSt6cGdMaTdRT1RycjhuVTlkWHMr
M1RyYzZyZUpYaEh5eE93VDQ9

3. When someone logs in successfully, I set the user_id value in the
session variable. Right then I see that the sql record has the value in
"data" variable changed.

session[:user_id] = params[:email]

4. When someone logs out, I clear the value and call reset_session.
Again I see the sql record has the "data" variable with changed value.

session[:user_id] = nil
reset_session

Hence the problem is:
1. Can't I ensure a session record is created only when I want - After
the user logs in ?
2. If not, Can I differentiate a authenticated session vs
unauthenticated sessions (sessions where the login page was just loaded
OR sessions where the user logged out) ?

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f8388030ab36150acee739a54235ca2b%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment