<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jefim Borissov &#187; Ruby (on Rails)</title>
	<atom:link href="http://jefim.eu/blog/tag/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://jefim.eu/blog</link>
	<description>Житие мое</description>
	<lastBuildDate>Fri, 05 Aug 2011 22:28:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>RoR: Session / login management</title>
		<link>http://jefim.eu/blog/2009/11/ror-session-login-management/</link>
		<comments>http://jefim.eu/blog/2009/11/ror-session-login-management/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 15:01:32 +0000</pubDate>
		<dc:creator>Jefim</dc:creator>
				<category><![CDATA[Assorted]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[Ruby (on Rails)]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://jefim.eu/blog/?p=269</guid>
		<description><![CDATA[This is basic yet not obvious in Ruby on Rails - I've been looking for info on this for a long time (a long time for this problem is anything more than 5 minutes). So, this is the way you make sessions/logins work in ruby: class SessionController < ApplicationController def login @session['logged'] = true end [...]]]></description>
			<content:encoded><![CDATA[<p>This is basic yet not obvious in Ruby on Rails - I've been looking for info on this for a long time (a long time for this problem is anything more than 5 minutes).</p>
<p>So, this is the way you make sessions/logins work in ruby:</p>
<pre name="code" class="ruby">
class SessionController < ApplicationController
  def login
    @session['logged'] = true
  end
  def logout
    @session['logged'] = false
  end
end
</pre>
<p>The @session variable is available anywhere. Use it anywhere. For example you could come up with the following view showing whether the user is logged in:</p>
<pre name="code" class="ruby">
&lt;p&gt;Logged in: &lt;%= @session['logged'] %&gt; &lt;/p&gt;
</pre>
<p>And that is it. Anything beyond that (like adding a User model etc.) is out of this post's target. There are many articles on those things yet no clear explanation where to find and how to init a session. As you can see - the answer is clear - you don't <img src='http://jefim.eu/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  <strong>The session is already there. Just start using it.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://jefim.eu/blog/2009/11/ror-session-login-management/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

