Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor Session is not defined

Tags:

session

meteor

when I run my meteor project, this problem occurred:

ReferenceError: Session is not defined
at app/_components/talk/views/friends_list.coffee.js:1:16
at /home/xyz/web/edp/.meteor/local/build/server/server.js:298:12
at Array.forEach (native)
at Function._.each._.forEach (/home/xyz/.meteorite/meteors/meteor/
    meteor/9bb2b5447e845c4f483df5e9b42a2c1de5ab909b/
    dev_bundle/lib/node_modules/underscore/underscore.js:78:11)

here is my directory structure (I have changed the name of the files):

├── _components
│   ├── project_form
│   │   └── client
│   │       ├── lib
│   │       │   └── ...
│   │       ├── project_info
│   │       │   ├── x1.coffee
│   │       │   ├── x2.html
│   │       │   ├── x3.coffee
│   │       │   └── x4.html
│   │       └── views
│   │           ├── x5.coffee
│   │           └── x6.html
│   ├── README.md
│   └── talk
│       └── client
│             ├── x7.coffee
│             ├── x8.html
│             ├── x9.coffee
│             ├── x10.html
│             ├── x11.coffee
│             ├── x12.html
│             ├── x13.coffee
│             ├── x14.html
│             └── x15.less

If I change the directory structure to the following, meteor runs correctly.I really don't know why, how could it happened? I think the file loading order may make a difference to it. But I can't figure it out.

├── _components
│   ├── project_form
│   │   └── client
│   │       ├── lib
│   │       │   └── ...
│   │       ├── project_info
│   │       │   ├── x1.coffee
│   │       │   ├── x2.html
│   │       │   ├── x3.coffee
│   │       │   └── x4.html
│   │       └── views
│   │           ├── x5.coffee
│   │           └── x6.html
│   ├── README.md
│   └── talk
│       └── client
│           └── views
│               ├── x7.coffee
│               ├── x8.html
│               ├── x9.coffee
│               ├── x10.html
│               ├── x11.coffee
│               ├── x12.html
│               ├── x13.coffee
│               ├── x14.html
│               └── x15.less
like image 203
user2483084 Avatar asked Jun 13 '13 16:06

user2483084


People also ask

How do I use Session on meteor?

Sessions are used for saving data while the users are using the app. This data will be deleted when the user leaves the app. In this chapter, we will learn how to set a session object, store some data, and return that data. We will use the basic HTML setup.

What is session in meteor?

Session provides a global object on the client that you can use to store an arbitrary set of key-value pairs. Use it to store things like the currently selected item in a list.


1 Answers

This might be happening because Session only works on the client and at app/_components/talk/views/friends_list.coffee.js it would also be run on the server.

You might want to move all your views/client side stuff into the /client directory or place it in:

if(Meteor.isClient) {

}
like image 63
Tarang Avatar answered Oct 01 '22 15:10

Tarang