Hi Developers!
1. I would like to know where the variables of $_SESSION['variablename'] are beeing set up by Phoenix?
I could not find that piece of code yet.
2. How can I set $_SESSION['languages_id'] (Language) to a different value like '2' -> german?
Thanks for a feedback.
$_SESSION variables
-
frankl
- Builder
- Posts: 159
- Joined: Tue Feb 23, 2021 8:39 pm
- Phoenix Version: v1.1.0.4
- Has thanked: 17 times
- Been thanked: 25 times
Re: $_SESSION variables
When would you like to set it? On initial page load by customer? After login?
Check out my addons - app.php/addons/author/frankl/contributions
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: $_SESSION variables
1. All over the place. They are usually given their initial values in the system hooks.
2. Just change German to be the default. Remove any languages that you don't want to use.
User guide link to setting up languages: https://phoenixcart.org/phoenixcartwiki ... _Languages
You also may want to make sure that your browser's Accept Language header is configured correctly: https://www.w3.org/International/questi ... priorities
Phoenix uses the Accept Language header to guess at what the user wants the language to be.
You can also turn on the language module in the header to allow the user to select a different language.
2. Just change German to be the default. Remove any languages that you don't want to use.
User guide link to setting up languages: https://phoenixcart.org/phoenixcartwiki ... _Languages
You also may want to make sure that your browser's Accept Language header is configured correctly: https://www.w3.org/International/questi ... priorities
Phoenix uses the Accept Language header to guess at what the user wants the language to be.
You can also turn on the language module in the header to allow the user to select a different language.
-
Philo2005
- Member
- Posts: 49
- Joined: Fri Mar 26, 2021 7:20 am
- Phoenix Version: v1.0.8.0
- Has thanked: 28 times
- Been thanked: 3 times
Re: $_SESSION variables
I did a try on login.php page after postLogin hook with the following statements and tried to get the language code set properly by using the parameter ?language=xx (where xx is the language code "en" or "de" in my configuration) in the url. This is my draft which should hopefully do the job:
Code: Select all
$customers_query = tep_db_query("SELECT c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_language_id FROM customers c WHERE c.customers_id = '" . (int)$login_customer_id. "'");
$customers = tep_db_fetch_array($customers_query);
$lng = $customers['customers_language_id'];
$languages_string = '';
$languages_query = tep_db_query("SELECT la.languages_id, la.code FROM languages la WHERE la.languages_id = '" . (int)$lng . "'");
$languages = tep_db_fetch_array($languages_query);
$langcode = $languages['code'];
$langpara = "language=" . $langcode;
$back = sizeof($_SESSION['navigation']->path)-2;
tep_redirect(tep_href_link($_SESSION['navigation']->path[$back]['page'], $langpara));
I was not able to successfully set the $_SESSION["languages_id"] to change the language shown in the session.
The way over url parameters now works.
The $back stuff I got this statements from another add-on. This sets the previous url.
-
14Steve14
- Senior Contributor
- Posts: 922
- Joined: Fri Oct 25, 2019 7:01 pm
- Phoenix Version: v1.0.9.1
- Has thanked: 17 times
- Been thanked: 103 times
Re: $_SESSION variables
I am not a coder but I do believe that the TEP function was deprecated many years ago. Not to sure what the replacement is but @raiwa has a helpful spreadsheet listed in his signature I believe that lists all the replacements.
- burt
- Core Team
- Posts: 4551
- Joined: Tue Oct 29, 2019 9:37 am
- Phoenix Version: v1.1.0.8
- : Buy Me A Beverage
- Has thanked: 252 times
- Been thanked: 412 times
Re: $_SESSION variables
Why not just turn on the languages box or navbar module?Philo2005 wrote: ↑Wed Mar 05, 2025 3:30 pm Hi Developers!
1. I would like to know where the variables of $_SESSION['variablename'] are beeing set up by Phoenix?
I could not find that piece of code yet.
2. How can I set $_SESSION['languages_id'] (Language) to a different value like '2' -> german?
Thanks for a feedback.
Your customer could then choose which language to browse in.
You seem to be allowing the user to set what language they want to browse in.
The question is "why?"...as that seems to be adding an unnecessary complication.
I am not here to build for you.
I am here to build with you. Let's help each other.
I am here to build with you. Let's help each other.
-
Philo2005
- Member
- Posts: 49
- Joined: Fri Mar 26, 2021 7:20 am
- Phoenix Version: v1.0.8.0
- Has thanked: 28 times
- Been thanked: 3 times
-
Philo2005
- Member
- Posts: 49
- Joined: Fri Mar 26, 2021 7:20 am
- Phoenix Version: v1.0.8.0
- Has thanked: 28 times
- Been thanked: 3 times
Re: $_SESSION variables
I do use this already
Well, I am using an add-on called "localize customer", which, among other things, stores the language on the table customers and orders when he opens a profile on my site and adds orders.
I want to make sure that the language set in the customer profile and orders is used for the view in the shop and correspondence from the shop! I also wondered for future whether it makes sense to store the respective currency in the customer and order base.
Since these are defined as system values ($_SESSION) in Phoenix, it is not so easy to change them when necessary and activate them in the following dialog. I tried in vain to set the values via $_SESSION.
But I have found a way to adopt these values via the URL (program code above).
That what I post as discussion code in the forum.
Hope you understand my opinion