Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I was wondering if it was a good practice to store the infos we retrieved from a DB (more specificaly the user infos) inside a session, useful for the login for example :
e.g :
$sql="SELECT * FROM USER";
$result=$myConnexion->query($sql);
$line=$result->fetch_assoc();
$_SESSION['login']=$line['login'];
$_SESSION['name']=$line['name'];
...
It then would be easier to display infos, welcome messages and so on.
What do you think ?
Thank you for your time
It's perfectly fine. Make sure you only store Public info you might need later on, meaning don't store the password or the user's ID in the db.
Yes, it's fine, as long as you don't store sensitive data, like the password, or the user name. You can check this for more
Using PHP SESSION Variables to store MySQL query results
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Yes, i looked for this question online, but I can not understand.
For example i know that when you log in you go to a link like :
site.com/Username
I know that you have to have a page for users in general like : user.php
but how exactly you put the name of the person at the account page when log in or the discription(do you read the name from the url and take other data from the database?).
I am new to php.
Please explain me
-Sorry for my english
The Best Way to do it is make a user.php page and when user login in
saves it's all data in session and when user open his profile/or
something else you can retrive data from session like user id and then
use your query to get the specific data against that user
You can store the username/id in $_SESSION['username'] or $_SESSION['id] like this. And can access the data of the user from the username/id. Hope this might help you.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have a some forms that stores data in my page.
I want to find a way to temporarily save the data entered by the user in navigating and keep until the order is confirmed.
Can anyone help me?
This is exactly what sessions are for
While I was working on e-commerce sites we used to keep all the order data
in sessions until user confirms order by going to payment gateway.
You can use PHP Session as arrays and store your data temporary and then destroy the session.
$_SESSION['cart'][] = //you data here
Sessions and cookies are used for this purpose but sessions are more secure and reliable.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
but did not understand
The concept of generating a link &
more importantly how they save the data in database,do they save it like id of poll & yes/no click or done with other logic.
what will happen to the polls which are expired? will they remain in database or somewhere else?
please help
To handle URL you can use cURL.
But I have an easy method. You can use the concept of Query Strings.
To Create New Question
Store the new question in database.Give Each Question a unique ID.
Then After user submits the questions show him a link like:
http://do-survey.com?question=xzxsa
To store polls
Get question like:
if(isset($_GET['question']))
{
$question = $_GET['question'];
// Now you have the question unique id manipulate the database using this
}
this is not the place to ask such questions, but to make my answer at least remotely useful:
they're not generating a link. That link doesn't exist under the form of a file on the server. Take for example a database containing 'id' 'poll' 'var1' 'var2'.
You can make a php page that gets a param from the link, have it like mysite.com/poll?id=1
The php script will get the '1' as a param, then you SELECT * FROM table WHERE id=1 and you generate the contents via php with the data from the DB.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have a some forms that stores data in my page.
I want to find a way to temporarily save the data entered by the user in navigating and keep until the order is confirmed.
Can anyone help me?
This is exactly what sessions are for
While I was working on e-commerce sites we used to keep all the order data
in sessions until user confirms order by going to payment gateway.
You can use PHP Session as arrays and store your data temporary and then destroy the session.
$_SESSION['cart'][] = //you data here
Sessions and cookies are used for this purpose but sessions are more secure and reliable.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have a some forms that stores data in my page.
I want to find a way to temporarily save the data entered by the user in navigating and keep until the order is confirmed.
Can anyone help me?
This is exactly what sessions are for
While I was working on e-commerce sites we used to keep all the order data
in sessions until user confirms order by going to payment gateway.
You can use PHP Session as arrays and store your data temporary and then destroy the session.
$_SESSION['cart'][] = //you data here
Sessions and cookies are used for this purpose but sessions are more secure and reliable.