//index.js where i start my session
exports.index = function(req, res){
req.session.username = "sachin";
console.log(req.session.username);
if(req.session.username)
{
console.log("Sessssion initialized");
}
res.render('index', { title: 'Express' });
};
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
//app.js
/** * Module dependencies. */
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = require('http')
, path = require('path')
, session = require('client-sessions');
var app = express();
app.use(session({
cookieName: 'session',
secret: 'cmpe273_test_string',
saveUninitialized: true, // (default: true)
resave: true,
duration: 30 * 60 * 1000,
activeDuration: 5 * 60 * 1000, }));
app.configure(function(){
app.set('port', process.env.PORT || 3070);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'routes')));
});
app.configure('development', function(){
app.use(express.errorHandler());
});
app.get('/', routes.index);
//orders.ejs////////////
<h3>Menu</h3>
<table class="table table-striped">
<thead><tr>
<th>Item Number</th>
<th>Item Name</th>
<th>Price</th>
</tr></thead>
<tbody><tr ng-repeat="item in items" >
<td>{{$index + 1}}</td>
<td>{{ item.Name }}</td>
<td>{{ item.price }}</td>
<td><input type="radio" name={{$index}} ng-click="cal(item.id)"<br> </td>
</tr></tbody>
</table>
<button class="btn" ng-click="res()">
<span class="glyphicon glyphicon-pencil"></span>Submit
</button>
//order.js
/**
* New node file */
var app = angular.module('myApp', []);
angular.module('myApp', []).controller('orderCtrl', function($scope) {
var json_responses
$scope.name = '';
$scope.price = '';
$scope.total=0;
$scope.output=0;
$scope.fina = [];
$scope.finals=[];
$scope.items = [
{id:1, Name:'Garlic Bread',price:20 },
{id:2, Name:'Butter Chicken',price:30 },
{id:3, Name:'Tandoori Chicken',price:25 },
{id:4, Name:'Naan',price:5},
{id:5, Name:'Ice Cream',price:10},
{id:6, Name:'Pizza',price:15 }
];
$scope.cal=function(id){
$scope.output = $scope.output+$scope.items[id-1].price;
$scope.fina.push({id:$scope.items[id-1], Name:$scope.items[id- 1].Name,price:$scope.items[id-1].price});
}
$scope.res=function(fina){
$scope.total= $scope.output;
$scope.finals=angular.copy($scope.fina);
}
});
When i select the buttons and submit and get the bill and then refresh the page all the data is lost. How do i get the data to stay even after refreshing?? Please help me out.