Drupal Sessions
Drupal sessions:
How Sessions works on drupal:
The page request send by the browser includes a 32-character ID known as PHPSESSID under set- cookie tag, which is used as the key to the session information that drupal stores about session.
-
The settings for session management are done in three files i.e. .htaccess, settings.php nad bootstarp.inc
-
By default drupal uses the cookie based session management instead of URL base session management. If the browser doesn’t accept cookies , a session cannot be established
-
-
The PHP directive ’sessions.use_only_cookies’ is set to 1 in settings.php to accept cookie based sessions.
-
The PHP directive ’sessions.use_trans_sid’ is set to 0 in settings.php to reject URL based sessions.
-
-
-
At the installation time Drupal turns off the PHP’s ’session.auto_start’ functionality in .htaccess file to take full control over sessions.
Why Drupal need sessions?
-
To handle the viewing preferences of the site content according to viewer status.
-
To remember the viewing preferences: Drupal stores sessions in ’sessions’ table, the session table is used to associate the sessions Ids with the user ids to retrieve the viewing preferences of a user. It applies a join query on session and user tables using session ids and user ids to know the user role. Session data of a user is viewable by $user->session of $user object.
-
-
To represent a session for anonymous user, the ’session’ table ‘uid’ column is set to 0.
-
To represent a session for login user, the ’session’ table ‘uid’ column is set to user Id with a new session Id such that the session does’nt get hijacked. If a user logs out, the row for that session is removed from the database immediately.
-
-
-
To remember the comments preferences: In comment.module session is used to store viewing preferences for users, i.e.
-
-
$_SESSIONS['comment_mode']=$mode
-
$_SESSIONS['comment_sort']=$order
-
$_SESSIONS['comment_comments_per_page']=$comments_per_page
-
-
-
To handle file uploads
Session Life time
-
Sessions lifetime related settings are located in settings.php, By default
-
-
ini_set(’session.cache_expire’, 200000); // 138.9 days
-
ini_set(’session.cookie_lifetime’, 2000000); // 23.1 days
-
ini_set(’session.gc_maxlifetime’, 200000); // 55 hours
-
-
Other Information
-
Writing session in the session table is the last task of drupal while serving pages.
-
Drupal does not store session information , the first time a user visits a site. This is to reduce the load on the sessions table generated by crawlers.
-
Drupal $user object is first built during the DRUPAL_BOOTSTRAP_SESSION phase of bootstrapping by sess_read().
-
While deploying drupal on multiple subdomains, you can create a unique session name for each site by adding ini_set(’session.name’, ‘my-site-unique-name_PHPSESSID’); in settings.php
-
If you need to store short term data for anonymous users, use the $_SESSION superglobal e.g.
-
-
$_SESSION['anonymous_data']=$anonymous_data;
-
-
-
If you want to store a permanent data to a user, save it in the $user object e.g.
-
-
$user->login_name=$login_name; user_save();
-
-
csmpqgbe7r

http://sites-development.narod.ru/56.html анкета на создание сайта [url=http://sites-development.narod.ru/58.html] аудит продвижения сайта [/url] аудит сайта оптимизация [url=http://sites-development.narod.ru/59.html] аудит сайта оптимизация [/url] cheap auto insurance [url=http://www.youtube.com/watch?v=WiPM2M8RavY] cheap auto insurance [/url] cheap car insurance [url=http://www.metacafe.com/watch/2758477/insrance_quotes_online_auto_home_life_health_other/] cheap car insurance [/url] car insurance [url=http://www.youtube.com/watch?v=CAcdtXAk_Xw] car insurance [/url]
http://sitesdevelopment.narod.ru/1802.html создание сетей сайтов [url=http://sitesdevelopment.narod.ru/1804.html] создание скриншотов сайта [/url] создание сложных сайтов [url=http://sitesdevelopment.narod.ru/1805.html] создание сложных сайтов [/url] cheap auto insurance [url=http://www.youtube.com/watch?v=WiPM2M8RavY] cheap auto insurance [/url] cheap car insurance [url=http://www.metacafe.com/watch/2758477/insrance_quotes_online_auto_home_life_health_other/] cheap car insurance [/url] car insurance [url=http://www.youtube.com/watch?v=CAcdtXAk_Xw] car insurance [/url]
Hello Bharat,
Thanks For Such a nice information i am new to drupal Can u please tell me if drupal does not save information at first visit how it come to know its the next visit of user
Regards
Vishal Arora
thanx vishal for taking interest in post:
Let me clear your confusion about the first visit of a user to drupal site, for your convinience i m giving u an example about how drupal interact with a first user , this example is similar to the one given in Apress Pro Drupal Developement book , you can reference it for the same:
Here is the example:
Firs visit:
visitor: hello can i see the page?
Druapl: please give me the identifiable cookie(i.e. the 32 bit character hash id)?
visitor: sorry i have no identifiable cookie.
Drupal: no problem i will give you a cookie for you and save it for your next visit.
Second visit:
visitor: hello can i see this page?
Drupal: sure, can i see your cookie(i.e. the 32 bit character hash id)?
visitor: here is my cookie.
Drupal: let me chk in my records do i have any info about your cookie….
Drupal: ok i got a similar entry in my records, means you are not a new visitor. let me create a session for you.
rOhklE xzzqbcxgkxhn, [url=http://rjhaxunsigob.com/]rjhaxunsigob[/url], [link=http://vrrmwlvuowxw.com/]vrrmwlvuowxw[/link], http://dyizkaxcvxkz.com/
http://sitedevelopment.narod.ru/867.html продвижение сайтов чебоксары [url=http://sitedevelopment.narod.ru/869.html] продвижение сайтов челябинск [/url] продвижение туристического сайта [url=http://sitedevelopment.narod.ru/870.html] продвижение туристического сайта [/url] cheap auto insurance [url=http://www.youtube.com/watch?v=WiPM2M8RavY] cheap auto insurance [/url] cheap car insurance [url=http://www.metacafe.com/watch/2758477/insrance_quotes_online_auto_home_life_health_other/] cheap car insurance [/url] car insurance [url=http://www.youtube.com/watch?v=CAcdtXAk_Xw] car insurance [/url]
http://sitesdevelopment.narod.ru/491.html оптимизация сайтов под гугл [url=http://sitesdevelopment.narod.ru/493.html] оптимизация сайтов под поисковые [/url] оптимизация сайтов разработка [url=http://sitesdevelopment.narod.ru/494.html] оптимизация сайтов разработка [/url] cheap auto insurance [url=http://www.youtube.com/watch?v=WiPM2M8RavY] cheap auto insurance [/url] cheap car insurance [url=http://www.metacafe.com/watch/2758477/insrance_quotes_online_auto_home_life_health_other/] cheap car insurance [/url] car insurance [url=http://www.youtube.com/watch?v=CAcdtXAk_Xw] car insurance [/url]
http://sitesdevelopment.narod.ru/1155.html раскрутка сайта продвижение бизнеса [url=http://sitesdevelopment.narod.ru/1157.html] раскрутка сайта продвижение веб [/url] раскрутка сайта раскрутить сайт [url=http://sitesdevelopment.narod.ru/1158.html] раскрутка сайта раскрутить сайт [/url] cheap auto insurance [url=http://www.youtube.com/watch?v=WiPM2M8RavY] cheap auto insurance [/url] cheap car insurance [url=http://www.metacafe.com/watch/2758477/insrance_quotes_online_auto_home_life_health_other/] cheap car insurance [/url] car insurance [url=http://www.youtube.com/watch?v=CAcdtXAk_Xw] car insurance [/url]
http://sites-development.narod.ru/430.html оптимизация сайта seo [url=http://sites-development.narod.ru/432.html] оптимизация сайта yandex [/url] оптимизация сайта блог [url=http://sites-development.narod.ru/433.html] оптимизация сайта блог [/url] cheap auto insurance [url=http://www.youtube.com/watch?v=WiPM2M8RavY] cheap auto insurance [/url] cheap car insurance [url=http://www.metacafe.com/watch/2758477/insrance_quotes_online_auto_home_life_health_other/] cheap car insurance [/url] car insurance [url=http://www.youtube.com/watch?v=CAcdtXAk_Xw] car insurance [/url]
http://sites-development.narod.ru/1340.html скачать бесплатно создание сайта [url=http://sites-development.narod.ru/1342.html] скачать бесплатно учебник создание сайта [/url] скачать видеокурс по раскрутке сайта [url=http://sites-development.narod.ru/1343.html] скачать видеокурс по раскрутке сайта [/url] cheap auto insurance [url=http://www.youtube.com/watch?v=WiPM2M8RavY] cheap auto insurance [/url] cheap car insurance [url=http://www.metacafe.com/watch/2758477/insrance_quotes_online_auto_home_life_health_other/] cheap car insurance [/url] car insurance [url=http://www.youtube.com/watch?v=CAcdtXAk_Xw] car insurance [/url]
S6DEdv irwsggmocfnf, [url=http://ujwnebyhxruo.com/]ujwnebyhxruo[/url], [link=http://jykqsinbbajh.com/]jykqsinbbajh[/link], http://cabzhpvqzqeg.com/