I did some changes(added few tables) in database in other machine and imported that to my machine localhost , the session is not available , it only appears when I log in as Admin.
I tried update.php also, but didnt work.

Comments

cog.rusty’s picture

What do you mean "the session is not available"? Do you mean that there is no session cookie for anonymous users? Or what?

vinaykimi’s picture

I created my own login in front page. I did'nt take in consideration, anonymous user or authenticated user. Session is not available unless I go to admin page and log in.

cog.rusty’s picture

I still don't understand what "session is not available" means.

Can you explain what you see and what you expected to see?

vinaykimi’s picture

thanks for your response.

There is a user login and password in front page which is created by me . This is not a Drupal login(I am not using drupal login) , its my own login created in pagefront.tpl .
I am unable to enter into the website unless I login as admin in Drupal . After I login to Drupal , then I am able to login to my website through my front page login.

cog.rusty’s picture

Sorry, I don't understand. I don't even know what "enter into the website" means. Hopefully someone else will have an idea.

alan d.’s picture

The session and user is integrated in Drupal:

Eg:

<?php
  $user = db_fetch_object(db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = '%s'", $key));
?>

You should just let Drupal do it's own thing and use hook_user to integrate into whatever you are trying to do


Alan Davison
vinaykimi’s picture

I not using users table in Drupal , I am creating my own table which contains all login names and password, I created my own login boxes in pagefront.tpl in my theme

alan d.’s picture

k. As shown in the query above, the session user is a INNER JOIN of users / session. Without one, you can not have the other.

You will have to define your own session handler and try and mimic all of the required functionality that Drupal requires. You will probably need to clone your new "users" data into Drupal {users} table.

It would be better to describe what you are trying to do rather than to get help hacking Drupal functionality. It is a platform that is so flexible, it makes a great starting point for developing web applications.


Alan Davison
vinaykimi’s picture

I am using $_SESSION['username']= existing name in my database (registered user) .
I am creating above session varible in pagefront.tpl.php. In Drupal pages, I am giving condition as, if $_SESSION['username'] is set then only that page is displayed other wise it goes to front page. Problem occurs when I login then only anonymous user access my drupal pages. I am giving anonymous user permission in Admin/user/permissions in node module access content. but that is not working , I want Drupal pages to be viewed by anonymous user when his session is created.

alan d.’s picture

There are a number of issues here:

1) Session related

Drupal hijacks the session handling of PHP by defining it's own read/write/start/delete/etc. Normally when you call session_start, all values that were stored in $SESSION are returned.

When Drupal code is called, the values are queried from the database, the query is based on the user/session table join. This will always fail as your user data is in a non-drupal table. It will be impossible to log in or submit form data from within Drupal.

2) Simple redirect based on a session value

It would be easy to create a very simple module that implements hook_init()

Check for the value you want, if present, just do nothing. If it is absent, use drupal_goto to redirect the user to the page you want, adding an empty string will redirect you to your default front page

As in point 1 - you can not login using user data so I'm hoping that your thinking about testing something else here


Alan Davison
prabaharan.986’s picture

how fetch session variable in drupal pages

alan d.’s picture

The session is a super global, that is loaded very early in the Drupal bootstrap process:

<?php
echo $_SESSION['key of interest'];
?>

Alan Davison