Is there any way to pass a php variable which will be 'hidden' even if user check source code of my page?
up vote
0
down vote
favorite
when i use a code like,
<input type="hidden" name="foo" value="<?php echo $var;?>" />
the $var is displayed in source code of my web page. is there any way i can hide that variable from my users seeing in my source code by using PHP/Codeigniter? am using codeigniter for my project.
in short, what i want to do is send data to a controller when a form is submitted. but not through url or hidden html input fields
php html forms codeigniter codeigniter-3
add a comment |
up vote
0
down vote
favorite
when i use a code like,
<input type="hidden" name="foo" value="<?php echo $var;?>" />
the $var is displayed in source code of my web page. is there any way i can hide that variable from my users seeing in my source code by using PHP/Codeigniter? am using codeigniter for my project.
in short, what i want to do is send data to a controller when a form is submitted. but not through url or hidden html input fields
php html forms codeigniter codeigniter-3
I guess you'll have to pass through the value by using sessions.
– dn Fer
Nov 11 at 15:30
You can encrypt a hidden value.
– Progrock
Nov 11 at 18:20
It looks as if CI has an encryption library. codeigniter.com/user_guide/libraries/encryption.html
– Progrock
Nov 11 at 18:31
Does it matter if people see the value/variable?
– Progrock
Nov 11 at 18:32
Thanks for your replys guys. Both sessions and encrypting will do the job. I feel sessions work better for my project. Anyway thanks guys
– Rishad
Nov 11 at 22:32
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
when i use a code like,
<input type="hidden" name="foo" value="<?php echo $var;?>" />
the $var is displayed in source code of my web page. is there any way i can hide that variable from my users seeing in my source code by using PHP/Codeigniter? am using codeigniter for my project.
in short, what i want to do is send data to a controller when a form is submitted. but not through url or hidden html input fields
php html forms codeigniter codeigniter-3
when i use a code like,
<input type="hidden" name="foo" value="<?php echo $var;?>" />
the $var is displayed in source code of my web page. is there any way i can hide that variable from my users seeing in my source code by using PHP/Codeigniter? am using codeigniter for my project.
in short, what i want to do is send data to a controller when a form is submitted. but not through url or hidden html input fields
php html forms codeigniter codeigniter-3
php html forms codeigniter codeigniter-3
asked Nov 11 at 15:18
Rishad
179110
179110
I guess you'll have to pass through the value by using sessions.
– dn Fer
Nov 11 at 15:30
You can encrypt a hidden value.
– Progrock
Nov 11 at 18:20
It looks as if CI has an encryption library. codeigniter.com/user_guide/libraries/encryption.html
– Progrock
Nov 11 at 18:31
Does it matter if people see the value/variable?
– Progrock
Nov 11 at 18:32
Thanks for your replys guys. Both sessions and encrypting will do the job. I feel sessions work better for my project. Anyway thanks guys
– Rishad
Nov 11 at 22:32
add a comment |
I guess you'll have to pass through the value by using sessions.
– dn Fer
Nov 11 at 15:30
You can encrypt a hidden value.
– Progrock
Nov 11 at 18:20
It looks as if CI has an encryption library. codeigniter.com/user_guide/libraries/encryption.html
– Progrock
Nov 11 at 18:31
Does it matter if people see the value/variable?
– Progrock
Nov 11 at 18:32
Thanks for your replys guys. Both sessions and encrypting will do the job. I feel sessions work better for my project. Anyway thanks guys
– Rishad
Nov 11 at 22:32
I guess you'll have to pass through the value by using sessions.
– dn Fer
Nov 11 at 15:30
I guess you'll have to pass through the value by using sessions.
– dn Fer
Nov 11 at 15:30
You can encrypt a hidden value.
– Progrock
Nov 11 at 18:20
You can encrypt a hidden value.
– Progrock
Nov 11 at 18:20
It looks as if CI has an encryption library. codeigniter.com/user_guide/libraries/encryption.html
– Progrock
Nov 11 at 18:31
It looks as if CI has an encryption library. codeigniter.com/user_guide/libraries/encryption.html
– Progrock
Nov 11 at 18:31
Does it matter if people see the value/variable?
– Progrock
Nov 11 at 18:32
Does it matter if people see the value/variable?
– Progrock
Nov 11 at 18:32
Thanks for your replys guys. Both sessions and encrypting will do the job. I feel sessions work better for my project. Anyway thanks guys
– Rishad
Nov 11 at 22:32
Thanks for your replys guys. Both sessions and encrypting will do the job. I feel sessions work better for my project. Anyway thanks guys
– Rishad
Nov 11 at 22:32
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
You can use codeigniter's session library to store data which won't be visible in source code.
- Session library need to be loaded (
$this->load->library('session');
or autoload inapplication/config/autoload.php
) - In your controller set the data what you want to store (
$this->session->set_userdata(['your_secret_data_key' => 'your_secret_data_value']);
) - You can retrieve your data (
$this->session->userdata('your_secret_data_key');
)
So before you generate the form add the data, and in the controller which will process your form you can retrieve the previously stored data.
More info about the session library: Codeigniter's session library documentation
Thanks for the details. I feel This solution will be more practical as i have to deal with sessions already in my code. Also ecrypt and decrypt wont do the work as other can decrypt easily. Anyway thanks a ton for your time
– Rishad
Nov 11 at 22:18
add a comment |
up vote
0
down vote
You can use encryption library to encrypt this value before you send it to the view and upon retrieving it decrypt it again.
Loading the library: $this->load->library('encryption');
you can find more details in the documentation about its configurations.
encryption
$var = 'value';
$var = $this->encryption->encrypt($var);
$this->load->view('view', array('var' => $var));
Now you have an encrypted $var
, do whatever you have to do and upon retrieval you can just use this:
$var = $this->encryption->decrypt($var);
echo $var; // value
Thanks for the response. But i feel like setting session and destroying after use will be more helpful as anyone can decrypt my encrypted data.
– Rishad
Nov 11 at 22:20
@Rishad, it would be pretty pointless encryption if anyone could decrypt it. You'll be the only one with the key.
– Progrock
Nov 12 at 5:53
@Rishad, the question errs towards having some payload in the user submitted form. "i want to do is send data to a controller when a form is submitted". Sessions may be an alternative workaround for you. But sessions can dangle somewhat, you've a tight coupling to server side transient data that way.
– Progrock
Nov 12 at 6:00
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You can use codeigniter's session library to store data which won't be visible in source code.
- Session library need to be loaded (
$this->load->library('session');
or autoload inapplication/config/autoload.php
) - In your controller set the data what you want to store (
$this->session->set_userdata(['your_secret_data_key' => 'your_secret_data_value']);
) - You can retrieve your data (
$this->session->userdata('your_secret_data_key');
)
So before you generate the form add the data, and in the controller which will process your form you can retrieve the previously stored data.
More info about the session library: Codeigniter's session library documentation
Thanks for the details. I feel This solution will be more practical as i have to deal with sessions already in my code. Also ecrypt and decrypt wont do the work as other can decrypt easily. Anyway thanks a ton for your time
– Rishad
Nov 11 at 22:18
add a comment |
up vote
2
down vote
accepted
You can use codeigniter's session library to store data which won't be visible in source code.
- Session library need to be loaded (
$this->load->library('session');
or autoload inapplication/config/autoload.php
) - In your controller set the data what you want to store (
$this->session->set_userdata(['your_secret_data_key' => 'your_secret_data_value']);
) - You can retrieve your data (
$this->session->userdata('your_secret_data_key');
)
So before you generate the form add the data, and in the controller which will process your form you can retrieve the previously stored data.
More info about the session library: Codeigniter's session library documentation
Thanks for the details. I feel This solution will be more practical as i have to deal with sessions already in my code. Also ecrypt and decrypt wont do the work as other can decrypt easily. Anyway thanks a ton for your time
– Rishad
Nov 11 at 22:18
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You can use codeigniter's session library to store data which won't be visible in source code.
- Session library need to be loaded (
$this->load->library('session');
or autoload inapplication/config/autoload.php
) - In your controller set the data what you want to store (
$this->session->set_userdata(['your_secret_data_key' => 'your_secret_data_value']);
) - You can retrieve your data (
$this->session->userdata('your_secret_data_key');
)
So before you generate the form add the data, and in the controller which will process your form you can retrieve the previously stored data.
More info about the session library: Codeigniter's session library documentation
You can use codeigniter's session library to store data which won't be visible in source code.
- Session library need to be loaded (
$this->load->library('session');
or autoload inapplication/config/autoload.php
) - In your controller set the data what you want to store (
$this->session->set_userdata(['your_secret_data_key' => 'your_secret_data_value']);
) - You can retrieve your data (
$this->session->userdata('your_secret_data_key');
)
So before you generate the form add the data, and in the controller which will process your form you can retrieve the previously stored data.
More info about the session library: Codeigniter's session library documentation
answered Nov 11 at 15:38
fff
534
534
Thanks for the details. I feel This solution will be more practical as i have to deal with sessions already in my code. Also ecrypt and decrypt wont do the work as other can decrypt easily. Anyway thanks a ton for your time
– Rishad
Nov 11 at 22:18
add a comment |
Thanks for the details. I feel This solution will be more practical as i have to deal with sessions already in my code. Also ecrypt and decrypt wont do the work as other can decrypt easily. Anyway thanks a ton for your time
– Rishad
Nov 11 at 22:18
Thanks for the details. I feel This solution will be more practical as i have to deal with sessions already in my code. Also ecrypt and decrypt wont do the work as other can decrypt easily. Anyway thanks a ton for your time
– Rishad
Nov 11 at 22:18
Thanks for the details. I feel This solution will be more practical as i have to deal with sessions already in my code. Also ecrypt and decrypt wont do the work as other can decrypt easily. Anyway thanks a ton for your time
– Rishad
Nov 11 at 22:18
add a comment |
up vote
0
down vote
You can use encryption library to encrypt this value before you send it to the view and upon retrieving it decrypt it again.
Loading the library: $this->load->library('encryption');
you can find more details in the documentation about its configurations.
encryption
$var = 'value';
$var = $this->encryption->encrypt($var);
$this->load->view('view', array('var' => $var));
Now you have an encrypted $var
, do whatever you have to do and upon retrieval you can just use this:
$var = $this->encryption->decrypt($var);
echo $var; // value
Thanks for the response. But i feel like setting session and destroying after use will be more helpful as anyone can decrypt my encrypted data.
– Rishad
Nov 11 at 22:20
@Rishad, it would be pretty pointless encryption if anyone could decrypt it. You'll be the only one with the key.
– Progrock
Nov 12 at 5:53
@Rishad, the question errs towards having some payload in the user submitted form. "i want to do is send data to a controller when a form is submitted". Sessions may be an alternative workaround for you. But sessions can dangle somewhat, you've a tight coupling to server side transient data that way.
– Progrock
Nov 12 at 6:00
add a comment |
up vote
0
down vote
You can use encryption library to encrypt this value before you send it to the view and upon retrieving it decrypt it again.
Loading the library: $this->load->library('encryption');
you can find more details in the documentation about its configurations.
encryption
$var = 'value';
$var = $this->encryption->encrypt($var);
$this->load->view('view', array('var' => $var));
Now you have an encrypted $var
, do whatever you have to do and upon retrieval you can just use this:
$var = $this->encryption->decrypt($var);
echo $var; // value
Thanks for the response. But i feel like setting session and destroying after use will be more helpful as anyone can decrypt my encrypted data.
– Rishad
Nov 11 at 22:20
@Rishad, it would be pretty pointless encryption if anyone could decrypt it. You'll be the only one with the key.
– Progrock
Nov 12 at 5:53
@Rishad, the question errs towards having some payload in the user submitted form. "i want to do is send data to a controller when a form is submitted". Sessions may be an alternative workaround for you. But sessions can dangle somewhat, you've a tight coupling to server side transient data that way.
– Progrock
Nov 12 at 6:00
add a comment |
up vote
0
down vote
up vote
0
down vote
You can use encryption library to encrypt this value before you send it to the view and upon retrieving it decrypt it again.
Loading the library: $this->load->library('encryption');
you can find more details in the documentation about its configurations.
encryption
$var = 'value';
$var = $this->encryption->encrypt($var);
$this->load->view('view', array('var' => $var));
Now you have an encrypted $var
, do whatever you have to do and upon retrieval you can just use this:
$var = $this->encryption->decrypt($var);
echo $var; // value
You can use encryption library to encrypt this value before you send it to the view and upon retrieving it decrypt it again.
Loading the library: $this->load->library('encryption');
you can find more details in the documentation about its configurations.
encryption
$var = 'value';
$var = $this->encryption->encrypt($var);
$this->load->view('view', array('var' => $var));
Now you have an encrypted $var
, do whatever you have to do and upon retrieval you can just use this:
$var = $this->encryption->decrypt($var);
echo $var; // value
answered Nov 11 at 21:51
Sherif Salah
38827
38827
Thanks for the response. But i feel like setting session and destroying after use will be more helpful as anyone can decrypt my encrypted data.
– Rishad
Nov 11 at 22:20
@Rishad, it would be pretty pointless encryption if anyone could decrypt it. You'll be the only one with the key.
– Progrock
Nov 12 at 5:53
@Rishad, the question errs towards having some payload in the user submitted form. "i want to do is send data to a controller when a form is submitted". Sessions may be an alternative workaround for you. But sessions can dangle somewhat, you've a tight coupling to server side transient data that way.
– Progrock
Nov 12 at 6:00
add a comment |
Thanks for the response. But i feel like setting session and destroying after use will be more helpful as anyone can decrypt my encrypted data.
– Rishad
Nov 11 at 22:20
@Rishad, it would be pretty pointless encryption if anyone could decrypt it. You'll be the only one with the key.
– Progrock
Nov 12 at 5:53
@Rishad, the question errs towards having some payload in the user submitted form. "i want to do is send data to a controller when a form is submitted". Sessions may be an alternative workaround for you. But sessions can dangle somewhat, you've a tight coupling to server side transient data that way.
– Progrock
Nov 12 at 6:00
Thanks for the response. But i feel like setting session and destroying after use will be more helpful as anyone can decrypt my encrypted data.
– Rishad
Nov 11 at 22:20
Thanks for the response. But i feel like setting session and destroying after use will be more helpful as anyone can decrypt my encrypted data.
– Rishad
Nov 11 at 22:20
@Rishad, it would be pretty pointless encryption if anyone could decrypt it. You'll be the only one with the key.
– Progrock
Nov 12 at 5:53
@Rishad, it would be pretty pointless encryption if anyone could decrypt it. You'll be the only one with the key.
– Progrock
Nov 12 at 5:53
@Rishad, the question errs towards having some payload in the user submitted form. "i want to do is send data to a controller when a form is submitted". Sessions may be an alternative workaround for you. But sessions can dangle somewhat, you've a tight coupling to server side transient data that way.
– Progrock
Nov 12 at 6:00
@Rishad, the question errs towards having some payload in the user submitted form. "i want to do is send data to a controller when a form is submitted". Sessions may be an alternative workaround for you. But sessions can dangle somewhat, you've a tight coupling to server side transient data that way.
– Progrock
Nov 12 at 6:00
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53250141%2fis-there-any-way-to-pass-a-php-variable-which-will-be-hidden-even-if-user-chec%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I guess you'll have to pass through the value by using sessions.
– dn Fer
Nov 11 at 15:30
You can encrypt a hidden value.
– Progrock
Nov 11 at 18:20
It looks as if CI has an encryption library. codeigniter.com/user_guide/libraries/encryption.html
– Progrock
Nov 11 at 18:31
Does it matter if people see the value/variable?
– Progrock
Nov 11 at 18:32
Thanks for your replys guys. Both sessions and encrypting will do the job. I feel sessions work better for my project. Anyway thanks guys
– Rishad
Nov 11 at 22:32