![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
[...] Thomas 'PointedEars' Lahn [...] wrote: writeSessionCookie() contained in scripts/cookies.js included via the `script' element is declared *client-side* as document.write() works only client-side. Everything inside <% ... %> is executed *server-side*. IOW, neither method is just not there when you call it. Hence the error message. This is the second time you demonstrate a complete lack of understanding for client-side and server-side scripting. You should finally learn the basics and the basic difference between the two before you continue this half-knowledged messing around. [...] Slowly learning... |
|
So I know now that ASP renders the page BEFORE Javascript. |
|
In that case in the sample below, is it possible to use session cookie values (read on client side) (email and pword) to select from a table (server side sql) (the example uses Request() set in previous page: looking to replace them with the variables). |
#2
| |||
| |||
|
|
You should then evaluate the header value in order to generate the proper response body via ASP. |
#3
| |||
| |||
|
|
You should then evaluate the header value in order to generate the proper response body via ASP. I'm not sure what you mean |
|
SQL statement (I accept the security implications for now). It's the syntax of the IF and SQL statements I'm trying to code. script type="text/javascript" var email = getCookieValue('email'); //already set in previous page var pword = getCookieValue('pword'); //already set in previous page /script % var strSql; //if ((Request("email") != "") && (Request("pword") != "")) { if ((%>email<% != "") && (%>pword<% != "")) { strSql = "SELECT email, pword FROM logintable where email = '" + email + "' and pword = '" + pword + "';"; // more code.... % |
#4
| |||
| |||
|
|
I guess the main gotcha is that in the source both kind of instructions are oftenly staying together, so forcing into a fake assumption "close on the screen - close in the life". Some may have a better idea. |
#5
| |||
| |||
|
|
I guess the main gotcha is that in the source both kind of instructions are oftenly staying together, so forcing into a fake assumption "close on the screen - close in the life". Some may have a better idea. Ah Ok I see. Perhaps your reply could be put into the FAQ? It was very succinct. |
|
If I understand what you're saying then, the (server-side) SQL statement in the <% %> 'tags' below won't contain the values from the variables, because the (client-side) <script></script> values haven't been retrieved yet? |
|
So is there a way of using values retrieved from a cookie in an SQL statement then? |
#6
| |||
| |||
|
|
Setting and reading cookie is not an exclusive privilege of Javascript. Any server can do it (if accepted by client). If there are cookies for given domain, they are being sent as part of request header from client to server: no custom Javascript needed, it is done by browser itself. So in your ASP block server-side you may check for the presence of cookie and use them in any way you need them. If cookies are not set yet, you can prepare and set them via the response header from your server. |
#7
| |||
| |||
|
|
On Feb 3, 4:36 pm, VK <schools_r... (AT) yahoo (DOT) com> wrote: Setting and reading cookie is not an exclusive privilege of Javascript. Any server can do it (if accepted by client). If there are cookies for given domain, they are being sent as part of request header from client to server: no custom Javascript needed, it is done by browser itself. So in your ASP block server-side you may check for the presence of cookie and use them in any way you need them. If cookies are not set yet, you can prepare and set them via the response header from your server. Sorry I don't understand. How would I have to change the code posted to use the cookie values? I've used Request("email") in the SQL which works (the value is passed from previously SUBMITed page), however I would like to know how to use the value from the cookie, that was set in the previous page. The cookie value is retrieved with the custom javascript function getCookieValue() which has been included using <script type="text/ javascript" src = "scripts/cookies.js"></script>. Somewhere I need to call this function, to get the cookie value, to pass into the SQL statement. |
|
I'm really beginning to hate javascript :-( For what? For not being able to be executed client-side before |
![]() |
| Thread Tools | |
| Display Modes | |
| |