السلام عليك ورحمة الله وبركاته
كيف الاحوال يا شباب
ما المشكلة وين الفريق و ما سبب ذلك العطل ؟؟؟
كان عندي سؤال عن ASP :
ما الفرق بين cookies و session
ولا باس باعطائنا مثال توضيح بسيط ؟؟
حفظكم الله من كل مكروه
السلام عليك ورحمة الله وبركاته
كيف الاحوال يا شباب
ما المشكلة وين الفريق و ما سبب ذلك العطل ؟؟؟
كان عندي سؤال عن ASP :
ما الفرق بين cookies و session
ولا باس باعطائنا مثال توضيح بسيط ؟؟
حفظكم الله من كل مكروه

Hello,
Cookies arec a way of storing data about the user in his/her computer and retrieving these data later to identify them.When you use ASP code to write to Coockies ,a key and its value are written to a file in the user computer providing the user enable Cookies.
for example you can store the user name in Cookies ,so that you can greet him later when he come back to the site.In this case the key will be user and the value is the actual user name
Ex:user=gigaman
.You need to sepcifiy the expiry date
How to store this key and its value
<%
Response.Cookies("user")="gigaman"
Response.Cookies("firstname").Expires="May 10,2002"
%>
Now ,When the user comes back to your site you can greet him like:
<%
user = Request.Cookies("firstname")
Response.write "Weclome back " & user
Session is one of the IIS server-side objects
.quite good compared to using Cookies especially in database-driven web sites and where a client session has to be unique like E-commerce sites or even Forums like this forum.
For example you can ask the user to logon to the site and as soon as he does , you set the authenitcation to true ,so he does not need to logon again:
Session("authenticated")= true
Session("user") = gigaman
in the second line,we assume that you get the username from the database then you store it in the session.
Now if the user wants to do things like changing his account details you would want to know if he has already loged on.
IF Session("athenticated") = true then
here you allow him to change his details and you use the user value stored in the session object to constrcut your SQL query like:
"SELECT*FROM Users where Name='& Session("user") & "'"
ELSE
you redirect him to the logon page
END IF
values stored in the session will expire as soon as the user leaves the site or closes the browser
Tahiyati
Madani
هذا الموضوع مغلق.