I am trying to get some hands on Jaggery frameworks modules and i am facing problems in managing the sessions.
For eg Lets say the user is logging in and then logging out, but even after that when he presses the back button in browser in takes back the user to inner pages.
Here I am destroying the session on clicking Logout like session.invalidate();
but then to the user can traverse back.
Does anyone know how to solve this and manage sessions. Thanks !
To connect Jaggery to MySQL, you need to download JDBC driver jar to <jaggery>\carbon\repository\components\dropins\
directory.
In MySQL, create new database sodb by typing: mysql> create database sodb
.
the example below shows how to create table, insert data in MySQL and view the data using Jaggery.
Create sodb.jag file in the sodbmysql folder then add this code in the file:
<%
var query1 = "CREATE TABLE example(id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), age INT);";
config = {};
var db = new Database("jdbc:mysql://<mysql host>:<port>/<database>", "<mysql_username>", "<mysql_password>", config);
try{db.query(query1); print('Created the table');}
catch(e){print(e.toString());}
finally{db.close();}
%>
Start Jaggery server and go to: localhost:9763/sodbmysql/sodb.jag
.
Go to MySQL console> database sodb and enter this to view the table: mysql> show tables;
.
To insert the data from Jaggery application, change query to insert data to table:
var query1 ="INSERT INTO example (name, age) VALUES('Jad','34');"
.
To print in jaggery page, use:
var query1 = "SELECT * FROM example;"
or:
var results = db.query(query3);
print(results);
** For more information, check this link.