PHP session_start question/problem

Discussion in 'Programming' started by bigmike7801, Sep 30, 2009.

  1. #1
    I'm using the session_start() function in PHP to initialize session data for all of the login stuff on my website. However I just noticed that if I go to my website using www.domain.com it doesn't care the session variables over if I just go to domain.com (without the www).

    It works both ways like that. Is that normal? Can anything be done about it?
     
    bigmike7801, Sep 30, 2009 IP
  2. bigmike7801

    bigmike7801 Well-Known Member

    Messages:
    277
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Also, isn't there a way in htaccess to make my site automatically redirect from domain.com to www.domain.com?
     
    bigmike7801, Sep 30, 2009 IP
  3. Gold_Hunter

    Gold_Hunter Active Member

    Messages:
    147
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    63
    #3
    Sure, try this :

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
    RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
    Code (markup):
     
    Gold_Hunter, Oct 2, 2009 IP