As I put it in the question, how can I do to use a codeigniter session variable to a js file?
Now, there are certain things that should be known;
The first thing is: The session variables are in a file And where I want to use them is another file (.js).
The second thing is: I'm working the html and the Js in the same file.
and The Third is: That I am organizing my code and I am placing the files php, html, js c / u where it corresponds, that is, the js in your js folder, the html in your html folder and so on .. ..
and it happens that I no longer recognize the session variables of php codeigniter because when moving the entire script to its corresponding file, they do not exist in these session variables.
In Summary: Will there be any way to use php session variables in a Js file?
- > Knowing that they are 2 different files.
Here I leave the Code as I currently have it (all in the same .php file):
<script>
$(document).ready(function(){
var nom = "<?php print $this->session->userdata("sess_names"); ?>";
var ape = "<?php print $this->session->userdata("sess_apes"); ?>";
var ced = "<?php print $this->session->userdata("sess_cedu"); ?>";
...
</script>