Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Tell If a Session Is New
How To Tell If a Session Is New? - PHP Script Tips - Understanding and Using Sessions
✍: FYIcenter.com
There is not direct way to tell if a session is new or old. But you can design your site to have a required session value in all sessions. Then you can check the existence of this value in a session to determine if it is a new session by isset($_SESSION['name']).
Let's say you decided to have a required session value called "Status" with two possible values: "Guest" and "Registered". The landing script of your site should look like:
<?php session_start(); if (!isset($_SESSION['Status'])) { $_SESSION["Status"] = "Guest"; print("<html><pre>"); print("Welcome to FYICenter.com!\n"); print(" <a href=login.php>Login</a>\n"); print(" <a href=guest_home.php>Stay as a guest</a>\n"); print("</pre></html>\n"); } else { if ($_SESSION["Status"] == "Guest") { header( 'Location: http://localhost/guest_home.php'); } else if ($_SESSION["Status"] == "Registered") { header( 'Location: http://localhost/home.php'); } } ?>
2007-04-17, 5127👍, 0💬
Popular Posts:
What Happens If a Hyper Link Points to a Music File? - XHTML 1.0 Tutorials - Understanding Hyper Lin...
What print out will the folloging code produce? main() { char *p1=“name”; char *p2; p2=(char*)malloc...
What Is C Language? The C programming language is a standardized programming language developed in t...
How do we generate strong names ? or What is use the of SN.EXE ? or How do we apply strong names to ...
.NET INTERVIEW QUESTIONS - What is the difference between thread and process? A thread is a path of ...