Newbie - cookies and controller

I have a code which is using cookies.
If a code uses cookies INSIDE a method - program is working OK.
If a code uses cookies OUTSIDE any method - I am getting an error
message.

This code is issuing an error:

class UsersController < ApplicationController
  print cookies[:user] + "\n" # => Ruby does not like this code

  def new
    @user = User.new
    print cookies[:user] + "\n" # => Ruby loves this code
...

The error message is:
NameError in UsersController#new
undefined local variable or method `cookies' for UsersController:Class
RAILS_ROOT: C:/Aptana/boss7

When I remove the first "print" command - program is working
This is a code whicg\h is working:

class UsersController < ApplicationController

  def new
    @user = User.new
    print cookies[:user] + "\n"
...

Any ideas why?

Thanks,

Zalek

Please ask this on the ruby on rails forum/list.

···

On Dec 5, 2010, at 13:10 , ZalekBloom@hotmail.com wrote:

I have a code which is using cookies.
If a code uses cookies INSIDE a method - program is working OK.
If a code uses cookies OUTSIDE any method - I am getting an error
message.