Note that there are some explanatory texts on larger screens.

plurals
  1. POPhp cookie read/write sequence
    primarykey
    data
    text
    <p>I am submiting a php to itself through a dropdown that changes the page's interface language. While doing that I am updating a cookie that stores the <strong>HTML body TAG direction: rtl OR ltr</strong>.</p> <p>So while the <strong>HTML SELECT</strong> tag submits its value through a <strong>FORM onChage() func call</strong> to a JavaScript, and the Javascript reloads the <em>PHP</em> page, at the head of the <em>php</em> page there is an <em>INCLUDE</em> for the translation PHP page and when the page is rewritten the direction of the <em>BODY TAG</em> is to be updated according to language.</p> <p>Well, this actually reads the cookie <strong>BODY TAG DIR</strong> only the second time the language is changed, hence, body directions are not always correct.</p> <pre><code>&lt;?php header('Content-Type: text/html; charset=UTF-8'); include '../dbc.php'; mysql_query("SET NAMES 'UTF8'"); include './includes/getranslation.php'; ?&gt; &lt;html&gt; &lt;head&gt; &lt;SCRIPT language=JavaScript&gt; function reload(form) { var val=form.langselector.options[form.langselector.options.selectedIndex].value; SetCookie( 'lang', '' + val); self.location='login.php'; } &lt;/SCRIPT&gt; &lt;/head&gt; &lt;body dir='&lt;?php echo $_COOKIE['langdir']; ?&gt;'&gt; &lt;table width="100%" border="0" cellspacing="0" cellpadding="2" class="main"&gt; &lt;tr&gt; &lt;?php if ($_COOKIE["langdir"] == 'ltr') { $ddlangalignleftTD = 'right'; $ddlandalignrightTD = 'left'; } else { $ddlangalignleftTD = 'left'; $ddlandalignrightTD = 'right'; } ?&gt; &lt;td width="50%" align="&lt;?php echo $ddlangalignleftTD; ?&gt;" valign="center"&gt; &lt;?php echo $headingNamesArr['select_lang']; ?&gt;: &lt;/td&gt; &lt;td width="50%" align="&lt;?php echo $ddlandalignrightTD; ?&gt;" valign="center"&gt; &lt;form method="post" name="langselectorfrm" action="login.php"&gt; &lt;select name="langselector" onchange="reload(this.form)"&gt; &lt;?php echo '&lt;option value= ''&lt;/option&gt;'; ?&gt; &lt;/select&gt; &lt;/form&gt; </code></pre> <p><strong>I WOULD LIKE TO KNOW WHY IT DOES NOT READ THE UPDATED COOKIE, ONLY AFTER THE SECOND TIME IT IS SUBMITTED?</strong></p> <p>Hope you understand....</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload