Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session Variables

Status
Not open for further replies.

otgriffin

Programmer
Jan 21, 2003
8
US
Hello,

I am wanting to implement a session variable on my webpages using Dreamweaver Mx and PHP4. I am using a form to insert information from the user into a mysql database. I want to keep the user name and use it on the next pages until the user closes the browser. Can someone tell me how I can make this possible using session variables
 
[tt]

On your login user "server behavior" you already know that dreamweaver creates one session for you. Now all your have to do is add the rest of the field you want to capture in a session

etc...
MM_rsUser.Open
If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
Session("MM_Username") = MM_valUsername
Response.Cookies("firstname") = MM_rsUser("firstname")
Response.Cookies("lastname") = MM_rsUser("lastname")

etc...
etc...
you can set the cookie to expire -1 (today) so your user(s) log in everyday.


that will create your cookies. Now, when you want to check if cookies have been set have the user(s) log in and on each page they access you can put this at the top

<%
if request.cookies(&quot;firstname&quot;) = &quot;&quot; then
response.redirect &quot;Your_log_in_page.asp&quot;
end if
%>

* * * * * * * * * * *
<%=Tony%>
cold.gif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top