Forum Moderators: open
Often, I just set a session on every page, and test if it exists. This tells me if they are using cookies, but not if they are not.
eg.
[fixed]
if session("hassession")="y" then
response.write "we have a working session"
else
session("hassession")="y"
end if
[/fixed] I suppose you could write a little javascript which exectutes a little ajax or something when it can see a session cookie from the server. but then they doesnt neccessary mean they have been disabled either.
Here part of some old javascript of my mine which looks for a session cookie:
[fixed]
var thesession,thesessionn,thesessionv;
var allcookie = unescape(document.cookie);
var allcookies = allcookie.split(";");
for ( i = 0; i < allcookies.length; i++ ) {
acookie = allcookies[i].split("=");
acookie[0] = acookie[0].replace(/^\s+¦\s+$/g, '');
if (acookie[0].substring(0,10)=="ASPSESSION") {
thesessionn = acookie[0];
thesessionv = acookie[1].replace(/^\s+¦\s+$/g, '')}
}
[/fixed] "this website uses sessions. You will need to enable sessions in the browser settings in order to use this site"
At the moment I just have if <% if session("mysession") = "" then response.redirect("login.asp") %> but that won't tell the user why they can't login. Although perhaps I could make this clear on the login page.
Thanks for the help guys. Any other suggestions would also be appreciated.
<%
if request.form()<>"" then
if session("working")="ok" then
user = request.form("user")
pass = request.form("pass")
'... test user/pass ...
if ok then
response.redirect "home.asp"
response.end
end if
errmsg = "Your login credentials was incorrect."
else
errmsg = "Please enable cookies"
end if
end if
session("working")="ok"
response.write errmsg
%>
<p>
<form method=post>
<input name=user>
<input type=password name=pass>
<input type=submit value="login">
</form>