$_SESSION variables

Open to all! Ask other shopowners for help.
Post Reply
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

$_SESSION variables

Post by Philo2005 »

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.


Join The Code Co-op to get access to your library in the Code Co-op Forum
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

Post by frankl »

When would you like to set it? On initial page load by customer? After login?
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

Post by ecartz »

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.
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

Post by Philo2005 »

frankl wrote: Thu Mar 06, 2025 10:04 pm When would you like to set it? On initial page load by customer? After login?
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));
What do you think about my solution?
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: 923
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

Post by 14Steve14 »

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.
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: $_SESSION variables

Post by burt »

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.
Why not just turn on the languages box or navbar module?
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.
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

Post by Philo2005 »

14Steve14 wrote: Sat Mar 08, 2025 9:23 am @raiwa has a helpful spreadsheet listed in his signature I believe that lists all the replacements.
I am using an older version of phoenix, but thank you for the tip.
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

Post by Philo2005 »

burt wrote: Sat Mar 08, 2025 11:02 am [Why not just turn on the languages box or navbar module?
Your customer could then choose which language to browse in.
I do use this already
burt wrote: Sat Mar 08, 2025 11:02 am The question is "why?"
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 :shock: and my english :lol:


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply